[英]How Can I replace/copy all file and folder from one branch to another existing branch in GIT
[英]How can I copy files from a branch to another using git?
我有一个带有两个分支的 git 存储库: master
和gh-pages
。 如果我想将文件foo
从master
复制到gh-pages
而不合并它们。 我应该使用什么命令? 非常感谢。
你可以:
git checkout gh-pages
git checkout master foo
git commit -m 'Add file foo to gh-pages.'
如果您想比较 2 个分支之间的所有差异:您可以使用git difftool master gh-pages
或git difftool <SHA1 of gh-pages> .
如果您想获取特定文件列表的差异,请遵循以下步骤:
git diff master gh-pages -- path/to/file
也可以在提交foo后从master到gh-pages进行cherry-pick。(在cherry-pick 之后必须执行git add [path to foo]并提交)
我会这样做:当你提交时,你可以选择提交和推送什么。 所以只从master
提交foo
然后推送它,然后在 github/bitbucket 上将它合并到gh-pages
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.