3

My origin has a fixes and a fixes_v3 branch. My client has just fixes. I do a git pull git+ssh:/.../mygitrepo and suddenly on my client I have all the fixes_v3 code in the fixes branch. Why on earth did this happen? Now I try git pull ... mygitrepo fixes and it just tells me it's up to date.

git remote show origin gives this:

HEAD branch: fixes
Local refs configured for 'git push':
  fixes  pushes to fixes  (fast-forwardable)
  master pushes to master (up to date)
djechlin
  • 59,258
  • 35
  • 162
  • 290
  • I don't know the answer to your question, probably some bad setting, but I have one advice. [Don't `git pull`](http://longair.net/blog/2009/04/16/git-fetch-and-merge/). Use `git fetch` and `git merge` in two steps so you can see what you are merging with. – Shahbaz Jun 12 '12 at 15:11

2 Answers2

1

Apparently your branches are tracking the false remotes. Do a git remote show origin to see which branch remote branch fixes merges. It probably will say something like

fixes merges with remote fixes_v3

Adjust this accordingly after undoing your last merge.

pmr
  • 58,701
  • 10
  • 113
  • 156
  • @djechlin, your edit shows configuration for `git push`, not `git pull` – Shahbaz Jun 12 '12 at 15:49
  • @djechlin This is your issue. Your repos are not configured for `pull`. `git pull repo` is equivalent to `git fetch && git merge FETCH_HEAD` where `FETCH_HEAD` is the alphabetically first ref. The lesson here is probably, that you shouldn't pull without configuring for it. – pmr Jun 12 '12 at 15:53
  • Fair lesson. Basically `git fetch` is better functionality until you know what you're doing. Thanks. – djechlin Jun 12 '12 at 15:57
0

The quick fix?

Undo all local commits. E.g.

Select branch for undo

git branch fixes

Remove local commits

git reset --hard origin/fixes

Source

How did the topic branch get messed up?

In my case, I'd done a pull without naming the destination:

git pull origin cifs_support

Since there was no local cifs_support branch, the commits from origin/cifs_support were added to master.

Are you safe?

No. Check your config using the advice in the accepted answer: use git remote show origin to see which branches are affected by git pull and git push. If branch tracking is wrong, fix it ASAP.

Community
  • 1
  • 1
Donal Lafferty
  • 5,807
  • 7
  • 43
  • 60