t3chb0t
t3chb0t

Reputation: 18655

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 pushing.

Upvotes: 0

Views: 26

Answers (1)

ParthS007
ParthS007

Reputation: 2689

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!

Upvotes: 2

Related Questions