i did git pull --rebase and now i have everyone else's commit in my branch - why

Viewed 827

I did git pull --rebase and now I have everyone else's commit in my branch - why?

What happened:

Message 1:

Your branch and 'origin/Ang-1075' have diverged,
and have 33 and 1 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

nothing to commit, working tree clean

what I did

git pull -- rebase

Message 2

  (use "git push" to publish your local commits)

nothing to commit, working tree clean

what i did :

git push

now i have 66 file changes and lots of commits that aren't mine. I only had 2 commits on my branch...

Is there a way to revert this?

2 Answers

Your local copy of Ang-1075 has diverged from the remote version of that same branch, origin/Ang-1075.

1-2-3 <- local Ang-1075
 \
  2b-3b-4-5-6-...-33-34-...-66 <- origin/Ang-1075

You need to merge the local and remote versions of this branch together before the server will allow you to push the branch back up to the remote. After a git merge, it might look like this:

1-2-3--------------67 <- merge commit of origin/Ang-1075 into Ang-1075
 \                /
  2b-3b-........66

As long as you fetch and merge (i.e. git pull) and then push before anyone else pushes a new commit back up, the push should go through okay. I use normal merges rather than rebase, but I also create a new branch name for my changes if other people are active in that branch.

This happened because while you were committing to your local copy of the repo, other people pushed new commits to the same branch on the remote.

to fix this i did git pull --rebase origin master git push -f

Related