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) 
1
  • I don't know the answer to your question, probably some bad setting, but I have one advice. Don't git pull. Use git fetch and git merge in two steps so you can see what you are merging with. Commented Jun 12, 2012 at 15:11

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

3 Comments

@djechlin, your edit shows configuration for git push, not git pull
@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.
Fair lesson. Basically git fetch is better functionality until you know what you're doing. Thanks.
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.