简体   繁体   中英

Setup repository for pulling from GitHub but pushing to Company

I'm trying to setup a repository so that I can pull both from GitHub and a company internal repository but push (by default) only to the internal one and I'm confused about the proper steps I should take.

It looks like there are two approaches:

  1. You would create the internal repository, clone it, add another remove (with an alias) and then merge from GitHub by using --allow-unrelated-histories (will it require me to always use this switch or is it a one-time sync?)
  2. You would clone the GitHub repository and add a new upstream remote pointing to the internal repo that I would then use for push ing.

  • Which setup would be a better one?
  • Are there any signifficant dis/advantages of either one?
  • Or maybe there is yet another option?

The second option is more correct.

  • Clone the Repository from Github and this branch will be automatically set as origin branch.

  • Add the Internal remote branch as upstream by command: git remote add upstream <url_of_repo>

When pulling do this:

git pull origin <branch-name>

while pushing do this:

git push upstream <branch-name>

This the normal git flow and I don't think there will be any disadvantages of this flow.

I hope it helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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