[Development] Pushing rebases and unrelated changes together is a sin
Samuel Rødal
samuel.rodal at digia.com
Wed Feb 20 08:47:40 CET 2013
Hello,
it happens quite regularly that people do a rebase and in addition do
changes in the same push. It looks like this:
git pull --rebase # or cherry-pick or whatever you do
# do some changes
git commit -a --amend
git push gerrit HEAD:refs/for/some_branch
and it makes the diff between patch sets displayed by the Gerrit
interface (by choosing "Old Version History" to be other than Base)
totally unreadable.
The correct process when doing rebases is:
git pull --rebase # or your favorite git work-flow
git push gerrit HEAD:refs/for/some_branch
# add comment in change on gerrit about being a pure rebase
# do some changes
git commit -a --amend
git push gerrit HEAD:refs/for/some_branch
i.e. do rebases separately from changes (that are not essential for the
rebase).
Since it's a rather easy mistake to make (nothing in the interface
prevents you from doing it and a lot of people probably aren't even
aware of the correct process), how about we add some hook when pushing
to gerrit that detects rebases and displays something like this?
git push gerrit HEAD:refs/for/some_branch
WARNING: You're pushing a rebase, please confirm that you have not made
changes unrelated to the rebase (if you have, push the rebase first and
then the changes) [y/n]
At least that would give people a heads-up and the chance to correct
their mistake.
--
Samuel
More information about the Development
mailing list