Merges automatically fill in a message, like "Merge branch 'feature' into branch develop". I always leave these messages intact, so I can see what the branch that merged in used to be called. It's the only place this information is guaranteed to remain. If you delete these merge messages and the branches, that's it. You can't figure out what was what ever again.
I will checkout a new branch for some feature, work on it, then switch back to whatever branch I branched from - often master, but not always - then git merge --no-ff <feature branch>
. Here are some example commits from a project in which I've been rigging a character for animation:
* c117bff Make squash joint scaling uniform
* 9eb9ac2 Fix eyelid control limit
* b50c967 Merge branch 'lipWeightImprovements'
|\
| * 6f98ea7 Smooth cheek weighting
| * fdf3f91 Improve lip weights
|/
* 4434223 Merge branch 'hair'
|\
| * a3f3f89 Add hair controls for front half of head
| * 22a6bf4 Add joints for and weight front hair pieces
|/
* c338c14 Move archived script into archive/scripted folder
Note the two merge branches - each says "Merge branch 'whatever'". That's a unique aspect of the master branch, which I'm not really big fan of. If you merge to master, it doesn't put master in the merge message. If I had merged to, say, the 'release' branch, it would add "into release" to those messages. Even though I deleted the branch heads later, the merge messages tell me what those branches used to be called.
There are two things of note here:
- This graph was produced with
git log --all --decorate --graph --oneline
(those flags can be in any order). This group of 4 flags is so common that most people alias them, and I've seen all manner of alias names. I use la
for 'list all', and it's just those 4 flags. I also have las
and lass
for 'short' and 'super short' versions, and those just tack on, e.g. -10
and -25
flags, which are different numbers per machine I work on. I like las
to show a bit under half a screen's worth of listings, and lass
to show just under a quarter's worth. I also have lb
- 'list branch' - versions of those, which just leave off the -all
flag, so it only lists the history of the branch I'm on.
- When you make a commit, that moves to the top-left of this graph. The line of commits straight down the left side will be the 'first parents', meaning the commits that were merged into back through the history of your current branch. All branches that merge in come in from the left, always. Git will even draw a line through other lines to the right so it can wrap around the left in some cases, just so branches merging in always come in from the right, and merge in to the left. In this way you can always figure out what's going on in your history.
If you want my la/lb aliases, just run these commands:
git config --global alias.la 'log --oneline --graph --all --decorate'
git config --global alias.las 'log --oneline --graph --all --decorate -20'
git config --global alias.lass 'log --oneline --graph --all --decorate -8'
git config --global alias.lb 'log --oneline --graph --decorate'
git config --global alias.lbs 'log --oneline --graph --decorate -20'
git config --global alias.lbss 'log --oneline --graph --decorate -8'
That'll set it up for all repos (via your ~/.gitconfig file). Tweak the numbers to taste.