1

There is a project on GitHub that I follow (upstream):

https://github.com/adaptivecomputing/torque

I have a fork of this repo (origin):

https://github.com/spudstud/torque

New branches have been added to the upstream repository that I want to pull into origin, and then to my local machine.

According to GitHub help, this should be easy. I should be able synchronise my fork with the following commands. https://help.github.com/articles/syncing-a-fork

git fetch upstream
git merge upstream/master

Unfortunately, the upstream branches that I want (4.2.3, 4.2.3.1, 4.2.3.h2, 4.2.3.h3), still do not appear in origin

git clone git@github.com:spudstud/torque.git
cd torque/
git remote add upstream https://github.com/adaptivecomputing/torque.git
git remote -v
      origin    git@github.com:spudstud/torque.git (fetch)
      origin    git@github.com:spudstud/torque.git (push)
      upstream    https://github.com/adaptivecomputing/torque.git (fetch)
      upstream    https://github.com/adaptivecomputing/torque.git (push)
git fetch upstream
git checkout master
git merge upstream/master

git branch -a
* master
  remotes/origin/2.5-dev
  remotes/origin/2.5.12
  remotes/origin/4.1-dev
  remotes/origin/4.1.0
  remotes/origin/4.1.4
  remotes/origin/4.1.4-1648
  remotes/origin/4.1.5
  remotes/origin/4.1.5.1
  remotes/origin/4.1.5.2
  remotes/origin/4.2.0
  remotes/origin/4.2.1
  remotes/origin/4.2.2
  **** 4.2.3,  4.2.3.1,  4.2.3.h2,  4.2.3.h3 should show up about here^ ****
  ...
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/upstream/2.5-dev
  remotes/upstream/2.5.12
  remotes/upstream/4.1-dev
  remotes/upstream/4.1.0
  remotes/upstream/4.1.4
  remotes/upstream/4.1.4-1648
  remotes/upstream/4.1.5
  remotes/upstream/4.1.5.1
  remotes/upstream/4.1.6
  remotes/upstream/4.1.6.h1
  remotes/upstream/4.1.6.h2
  remotes/upstream/4.2-dev
  remotes/upstream/4.2.0
  remotes/upstream/4.2.1
  remotes/upstream/4.2.2
  remotes/upstream/4.2.2.ufl
  remotes/upstream/4.2.3
  remotes/upstream/4.2.3.1
  remotes/upstream/4.2.3.h2
  remotes/upstream/4.2.3.h3
  remotes/upstream/master

Nothing I have read so far can explain what the issue might be:

SOLUTION Thanks to the answers, I figured this out. I was not understanding that I needed to push the changes back to the fork:

git push origin 4.2.4

It appears that what I was trying to do was 'fast forward' my fork. GitHub used to have a fastforward button that would automatically bring your forked repository up to date with the upstream, Fast Forward Your Fork. It looks like GitHub got rid of the fast forward feature (as far as I can tell), so I'll have to repeat these steps for every branch.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
spuder
  • 17,437
  • 19
  • 87
  • 153
  • +1 for doing your homework. I would give you another +1 for also adding links to the Git repos, but I can only vote once ;) –  Jul 13 '13 at 06:18

2 Answers2

2

You are just merging the master branch. If you want to follow the upstream branches (I think that is what you want, the inline comment seems to be looking for 4.2.3, etc.) then you need to track them locally (assuming you want the changes available to peruse/edit) and then push them back to your fork.

git checkout -t upstream/4.2.3

Then push them back to your fork

git push origin 4.2.3

All fetch is doing is pulling the entire remote. When you git merge, your version just merges the upstream/master with your local/master.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
mateor
  • 1,293
  • 1
  • 16
  • 19
  • Thanks, While this does in theory work as a work around, it is not ideal because I will have to remember to push to my origin every time I commit. If I had write access to both upstream and origin, I could very easily push to the wrong repo. – spuder Jul 12 '13 at 22:52
  • You have to specify if you are pushing to somewhere other than origin. If you had write access to upstream, the only way to push there (if you cloned from a fork) is git push upstream . – mateor Jul 13 '13 at 02:22
  • If you really serious about needing to go to the remote only, use the force flag. After fetching from upstream, git push -f origin 4.2.3 – mateor Jul 13 '13 at 02:34
1

origin is your fork. The upstream repo is called upstream, and upstream/4.2.3, etc., exist. You can push them to your repository with $ git push origin upstream/4.2.3, etc. The two repos will not be synced automatically.

mipadi
  • 398,885
  • 90
  • 523
  • 479