[英]How can I copy files from a branch to another using git?
I have a git repository with two branches: master
and gh-pages
.我有一个带有两个分支的 git 存储库:
master
和gh-pages
。 If I want to copy a file foo
from master
to gh-pages
without merging them.如果我想将文件
foo
从master
复制到gh-pages
而不合并它们。 What command should I use?我应该使用什么命令? Many thanks.
非常感谢。
You can:你可以:
git checkout gh-pages
git checkout master foo
git commit -m 'Add file foo to gh-pages.'
If you want to compare all the diffs between 2 branches: you can use git difftool master gh-pages
or git difftool <SHA1 of gh-pages> .
如果您想比较 2 个分支之间的所有差异:您可以使用
git difftool master gh-pages
或git difftool <SHA1 of gh-pages> .
If you want to get diff for specific list of files follow this :如果您想获取特定文件列表的差异,请遵循以下步骤:
git diff master gh-pages -- path/to/file
也可以在提交foo后从master到gh-pages进行cherry-pick。(在cherry-pick 之后必须执行git add [path to foo]并提交)
The Way I would do it: When you commit you have a choice of what to commit and push.我会这样做:当你提交时,你可以选择提交和推送什么。 So commit only
foo
from master
then push it, Then just merge that on github/bitbucket whatever to gh-pages
所以只从
master
提交foo
然后推送它,然后在 github/bitbucket 上将它合并到gh-pages
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.