我有一个名为app.js的主分支。我在一个实验分支上对这个文件进行了更改。
我只想将实验中对app.js所做的更改应用到master分支。
我有一个名为app.js的主分支。我在一个实验分支上对这个文件进行了更改。
我只想将实验中对app.js所做的更改应用到master分支。
当前回答
要从另一个分支签出文件,只需简单的一行命令:
git checkout branch C:\path\to\file.cs
如果您想要多个文件
git checkout branch C:\path\to\file1.cs C:\path\to\file2.cs
其他回答
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> -- <paths>
更多信息
git checkout branch_name file_name
例子:
git checkout master App.java
如果分支名称中有句点,则此操作将不起作用。
git checkout "fix.june" alive.html
error: pathspec 'fix.june' did not match any file(s) known to git.
要从另一个分支签出文件,只需简单的一行命令:
git checkout branch C:\path\to\file.cs
如果您想要多个文件
git checkout branch C:\path\to\file1.cs C:\path\to\file2.cs
补充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