The Alpha Commit

I like to read commit logs. Today I wanted to see the first commit on a project. Here’s what I used: git rev-list --max-parents=0 HEAD Show me the commits that led to HEAD in reverse chronological order; then limit that list to the commits with no parent. Here’s a small modification, to show the entire commit rather than the SHA alone: git show $(git rev-list --max-parents=0 HEAD)

October 21, 2015

Git Log since

At the end of each day, I try to record what I did, to jog my memory during the next morning’s standup. This is a helpful aid: git log --since="24 hours ago" I SSH into my work machine and run this in my project’s root directory. Combined with an alias from the Hashrocket Dotmatrix, glg (git log --graph --oneline --decorate --color --all), I get a terse summary of the day’s work, ready to be pasted into your note-taking or project management tool of choice: ...

September 29, 2015

Git Snapshot

To save a snapshot of your current work in git, try this command: git stash save "snapshot: $(date)" && git stash apply "stash@{0}" This saves your current work in a timestamped stash, without removing it. In Hashrocket’s dotmatrix this command is aliased to git snapshot.

May 8, 2015

Undo a Git Mistake

git reflog is a record of your actions in Git. With this command, you can undo almost any Git mistake. $ git reflog 4bd0090 HEAD@{0}: <bad place> 46bd839 HEAD@{1}: <bad place> 967e214 HEAD@{2}: <last good place> 46bd839 HEAD@{3}: <good place> 967e214 HEAD@{4}: <good place> $ git reset --hard HEAD@{2}

April 21, 2015

Don’t miss my next essay

Hear from me immediately when I post: no ads, unsubscribe anytime.