简体   繁体   English

合并2个不同的git repos,从Heroku到GitHub

[英]Merge 2 different git repos, from Heroku to GitHub

I have a local git repo and a remote one on Heroku . 我在Heroku上有一个本地git repo和一个远程git repo。 They are in sync. 它们是同步的。 I am now added as a contributor to a GitHub repo that contains a couple of files in it. 现在,我被添加为其中包含几个文件的GitHub库的贡献者。

How do I push my local (or Heroku ) repo to the dev branch of this new GitHub repo that I don't own? 如何将我的本地(或Heroku )存储库推送到我不拥有的这个新GitHub库的dev分支中? I don't want to overwrite or delete anything. 我不想覆盖或删除任何内容。

  1. In your local git repository, add a remote repository that points to the GitHub repository: 在本地git存储库中, 添加一个指向GitHub存储库的远程存储库:

     git remote add upstream https://github.com/user/repo.git 
  2. Create a branch in your local git repository to stage the merge you're about to do: 在本地git存储库中创建一个分支,以分阶段要执行的合并:

     git checkout master git pull origin master git checkout -b feature/merge-local-to-remote 
  3. Perform a pull of the remote repository into your local copy, which will generate merge conflicts for any local git files that also exist in the GitHub repository: 将远程存储库拉入本地副本,这将为GitHub存储库中也存在的任何本地git文件生成合并冲突:

     git pull upstream master 
  4. Fix any merge conflicts that arise, making sure not to overwrite anything found in the GitHub repo that you want to preserve. 修复出现的任何合并冲突,确保不要覆盖要保留的GitHub存储库中的任何内容。 Then, commit all changes back to your local merge branch: 然后,将所有更改提交回本地合并分支:

     git add <the files you want to push to GitHub> git commit -m "fixing merge conflicts from upstream" 
  5. Push your branch to the GitHub repo as a branch: 将您的分支作为分支推送到GitHub库:

     git push upstream feature/merge-local-to-remote 

Create a pull request via the GitHub UI and verify that all of your git repo's contents made it to GitHub without overwriting anything. 通过GitHub UI创建拉取请求,并验证所有git repo的内容均已到达GitHub且未覆盖任何内容。

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

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