git copy [branch]中的文件并粘贴到其他[branch或master]下面

时间:2015-08-31 09:43:13

标签: git

我创建了存储库,如下所示......,

TestRepo.git
    |
    |_[Branch.Master]
             |____________Master.txt
    |_[Branch.Develop]
             |____________Develop.txt

我想复制Develop.txt并粘贴在[Branch.Master]下。

/// So I checkout Develop first.
$ git checkout Develop
/// Then I push develop.txt to remote/master
$ git push origin develop:master
/// Then I pull remote/master to my local/master.

然后我得到了下面的结果,这不是我想要的。

TestRepo.git
    |
    |_[Branch.Master]
             |____________Develop.txt
    |_[Branch.Develop]
             |____________Develop.txt

我想要的就像下面一样。

TestRepo.git
    |
    |_[Branch.Master]
             |____________Master.txt
             |____________Develop.txt
    |_[Branch.Develop]
             |____________Develop.txt

我不想被替换,我想要的只是追加。

感谢您的建议。

1 个答案:

答案 0 :(得分:1)

如果您要做的只是添加一个新文件,您只需将文件从源分支复制到目标分支。

git checkout master
git checkout Develop Develop.txt

然后添加文件,提交它,然后推出分支。

git add Develop.txt
git commit -m 'Added Develop.txt to the master branch'
git push origin master
相关问题