Do I have a forked remote set up properly on GitHub?

Viewed 40

My company's repo does not allow pushes to it so the process is to fork it and push to your fork and make a PR.

I have my remotes set up as follows:

$ git remote -v
origin git@github.com:heriettaLux/company-repo.git (fetch)  # my fork
origin git@github.com:heriettaLux/company-repo.git (push)   # my fork
upstream git@github.com:company-repo.git (fetch)
upstream git@github.com:company-repo.git (push)

Is there a better way to set this up?

I am on master now and when I do git log, I see:

$ git log
commit 21424... (HEAD -> master, upstream/master)
(Commit info)

commit 29128... (origin/master, origin/HEAD)
(Commit info)

I want to start a new feature branch but I can't tell if that means I am out of sync somehow? I just want to make sure I have the latest of my company's master pulled in so I can create a new branch off of it. I tried git pull origin master and git pull upstream master but both say it's up to date and now I'm thoroughly confused.

1 Answers

I would simply fetch from the company repository before creating the new feature branch:

git fetch upstream
git switch -c newBranch upstream/master

That way, I can start working from the most updated upstream master branch.

Then I can fetch regularly from upstream, and rebase my feature branch on top of it, in order to make sure my work remain based of the latest from the company repository.

Related