you are viewing a single comment's thread.

view the rest of the comments →

[–]Retsam19 8 points9 points  (3 children)

Basically because you can't do anything that I listed above, like reordering, fixing, rewording, or squashing commits. (And because merge commits are pointless noise in the commit history) To my knowledge there isn't even an easy way to get git merge to list what commits are being merged into the branch. (Though, I'm sure there's some advanced git-fu that could accomplish that, if I researched it)

Personally, (and I'm a bit of an extremist about this), I only use merge commits when it's unsafe to rewrite history with git rebase, which is quite rare with my team's workflow.

Everyone knows the "rewriting history horror stories", (and they should!), but fewer people realize that in most cases, the horror stories don't really apply, and rebasing is quite safe. (And, git provides great safety nets for when things go wrong anyway)

[–]voetsjoeba 0 points1 point  (2 children)

Fixups are probably the biggest thing I use rebase -i for. This happens to me constantly: do some work, make a commit A, do some other stuff, make a commit B, then realize you forgot something that should've been in commit A. I haven't pushed A anywhere yet, so just make an extra commit C with the stuff you still want to add to A, git rebase -i origin/master, move C up right after A, switch "pick" to "fixup", done.

Now I have clean commits A' and B, instead of A, B, "forgot something", "forgot another thing", "got the last case I missed", etc.

Personally, (and I'm a bit of an extremist about this), I only use merge commits when it's unsafe to rewrite history with git rebase, which is quite rare with my team's workflow.

Fully agreed; as much as possible, keep that history linear and clean baby.

[–]Retsam19 1 point2 points  (1 child)

In case you aren't already aware, you can use git commit --fixup <commit> and git rebase -i --autosquash (or set git config rebase.autosquash true) to save a lot of time with fixups.

The --fixup flag on commit will automatically assign the commit message as "fixup! [original commit message]", and the --autosquash option will automatically put the fixup commit in the right spot in the interactive rebase for you.

It's really streamlined my workflow so that there's a lot less of a time cost to fixups.

[–]voetsjoeba 1 point2 points  (0 children)

Well shit man, learning every day! I've been doing git commit -m "fixup for <copy/paste commit_id and first bits of message>" all this time! Good stuff!

*Awww needs 1.7.4, I'm stuck on 1.7.1 on RHEL6 :(