I enjoy learning new things. When I do, I’ll try to write them down in case others may perhaps also find them useful. If nothing else, the notes may help me when I’m wondering, “How did this get solved last time?”
My team at work is in the process of switch from Subversion to Git and GitHub. Git is new ground for many of us, as is the bash prompt (On Windows, Git includes a full-fledged bash prompt). Doing some troubleshooting today, I learned some new new things about both tools.
Pretty git logs
The first was a new Git command:
git log --graph --oneline
This creates a wonderful ASCII-art timeline, showing all your commits and showing how files have been merged into the project.
For a project of any complexity, this simple visualization is wonderful for understanding the flow of changes and merges by multiple developers. Check out this snippet from PhantomCSS for example:
blair@Squawk MINGW64 ~/test $ git log --graph --oneline * 20db940 0.10.4 * a482cc3 Merge pull request #127 from raveclassic/master |\ | * bbbaa22 fixed TypeError when calling phantomcss.compareAll() #68 * | e44196e Merge pull request #125 from shadowfiles/extension-settings |\ \ | * | 28a397f Added option to specify the suffix names of screenshot types. | |/ * | d8479cf Merge pull request #124 from renanborgez/patch-1 |\ \ | |/ |/| | * 4b0913f Update README.md |/ * 84945e5 0.10.2
Commit 4b0913f (near the bottom) updates the README.md and is then meged back in commit d8479cf. Meanwhile, a separate developer is adding new functionality in commit 28a397f, merges two pull requests in commits e44196e and bbbaa22 before everything comes back together in a482cc3
It’s a bit cryptic at first, but much easier to fathom than the straight up
The same format also appears, in a non-text based format, in the gitk tool.
A new (to me) bash command
The other new command was from bash. I’ve known for a while that your command line history is stored in ~/.bash_history, but I didn’t know what it was good for aside from presumably powering the up-arrow / down arrow line-at-a-time history.
Turns out that the
history command also displays your command line history, and it’s waaaaay more convenient than typing
more < ~/.bash_history
As a bonus, if you have multiple terminals open, this command is guaranteed to show the history for the current window rather than the one most recently closed.