1

I have a fork of F-Droid to submit small patches once in a while.
Once my changes have been merged, I would like to have exactly the same files as upstream.

PROBLEM: My fork has started "diverging" somehow. Even for the smallest change, Gitorious shows a lot of files, and for my latest patch upstream said:

I had to cherry-pick out the relevant commits, because your repo seems to have diverged so dramatically that the diff seems to show basically everything being changed

This is what I always do:

git pull upstream master
git push
<make my changes>
git commit -m "bla"
git push
<and then I send a merge request via Gitorious website>

What am I doing wrong?
It makes me sad to waste upstream's precious time.

Nicolas Raoul
  • 58,567
  • 58
  • 222
  • 373

1 Answers1

2

Don't pull, it will create a merge commit if it can't fast forward, likely the case if you have made some commit.

If you have commits not in the remote branch, just fetch and rebase on it.

Yann Droneaud
  • 5,277
  • 1
  • 23
  • 39
  • Do you mean fetch from my own remote branch, or fetch from upstream? – Nicolas Raoul Mar 01 '12 at 15:03
  • @NicolasRaoul fetch from upstream. – Yann Droneaud Mar 01 '12 at 15:05
  • @NicolasRaoul have a look at: git log --graph --oneline --decorate --all and you will probably see that your commits are not on top of origin/master (upstream): there's a merge that shouldn't be there. – Yann Droneaud Mar 01 '12 at 15:08
  • @NicolasRaoul btw, you should create dedicated branches for the merge. Such branches can be dropped once they are merged by upstream. – Yann Droneaud Mar 01 '12 at 15:10
  • Remember to not use rebase on a public branch because it rewrote history: people who "forked" from a public branch will be very disappointed after a rebase. – Yann Droneaud Mar 01 '12 at 15:35
  • Thanks! I ran `git fetch upstream` then `git rebase . Now `git status` says my "branch is behind 'origin/master' by 23 commits"... can I force a push to my origin/master? – Nicolas Raoul Mar 01 '12 at 15:37
  • Like before, but you will probably have to force a bit ... Have a look at http://stackoverflow.com/questions/559917/git-rebase-and-git-push-non-fast-forward-why-use and http://stackoverflow.com/questions/253055/how-do-i-push-amended-commit-to-the-remote-git-repo – Yann Droneaud Mar 01 '12 at 15:43
  • I forced push, and all seems to be as a new fork :-) – Nicolas Raoul Mar 02 '12 at 07:22