繁体   English   中英

将现有分支从一个存储库合并到新存储库的另一分支

[英]Merging an existing branch from one repository to another branch of a new repository

我在公司的github帐户中创建了一个新的存储库,并将自己添加为该存储库的贡献者。 我想将所有内容从用户A的存储库(usera.git)移到新创建的公司的存储库(company.git)。 我在计算机上克隆了用户A的存储库,因为我对此做出了贡献。 我还在usera.git的分支上进行了提交,让我们调用了brancha。 我想将brancha的整个历史以及我的暂存提交移至company.git存储库的master分支。

git remote -v
origin  https://github.com/usera/usera.git (fetch)
origin  https://github.com/usera/usera.git (push)

git remote add company https://github.com/company/company.git

git remote -v
company https://github.com/company/company.git (fetch)
company https://github.com/company/company.git (push)
origin  https://github.com/usera/usera.git (fetch)
origin  https://github.com/usera/usera.git (push)

git status
# On branch usera
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#   modified:   app/assets/javascripts/application.js.erb
#       ...

我目前不确定该怎么办。 目前,新创建的company.git是一个空的存储库。 我想将整个历史记录以及要提交的更改(我不想将更改提交到usera的存储库)移动到新的company.git存储库的master分支。 当我跑步

git fetch company

什么也没发生(通常您会看到诸如[new branch]之类的反馈)。 我运行“ git branch”,并且没有从公司存储库添加任何新的master分支。

我希望它能够拉下master分支,然后允许我检出该master分支,然后合并整个历史记录并进行更改。

没有远程主机可以下拉并合并; 如您所说, company回购是空的。

但这也意味着任何此类事情都是不必要的。 您可以执行git push company usera:master将本地分支usera推送到company上的master上。 您可以在该推送中添加-u选项,以使usera始终跟踪company/master ,或者之后可以使用git checkout创建新的分支跟踪company/master

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM