我有一个名为app.js的主分支。我在一个实验分支上对这个文件进行了更改。
我只想将实验中对app.js所做的更改应用到master分支。
我有一个名为app.js的主分支。我在一个实验分支上对这个文件进行了更改。
我只想将实验中对app.js所做的更改应用到master分支。
当前回答
补充VonC和chhh的答案:
git show experiment:path/to/relative/app.js > app.js
# If your current working directory is relative, then just use:
git show experiment:app.js > app.js
or
git checkout experiment -- app.js
其他回答
补充VonC和chhh的答案:
git show experiment:path/to/relative/app.js > app.js
# If your current working directory is relative, then just use:
git show experiment:app.js > app.js
or
git checkout experiment -- app.js
git checkout <branch_name> -- <paths>
更多信息
如果您想要来自特定提交(任何分支)的文件,请说06f8251f
git checkout 06f8251f path_to_file
例如,在Windows上:
git checkout 06f8251f C:\A\B\C\D\file.h
git checkout master -go to the master branch first
git checkout <your-branch> -- <your-file> --copy your file data from your branch.
git show <your-branch>:path/to/<your-file>
希望这对你有所帮助。如果你有任何疑问,请告诉我。
或者,如果您想要其他分支的所有文件:
git checkout <branch name> -- .