Delete Remote Git Tags

Tagging releases with Git is a good idea. In case your tags get off track, here is how you delete a Git tag locally and on a remote: $ git tag -d abc $ git push origin :refs/tags/abc To git@github.com:hashrocket/hr-til - [deleted] abc It gets trickier if you’re using Semantic Versioning, which includes dots in the tag name. The above won’t work for v16.0.0. This will: $ git tag -d v16.0.0 $ git push origin :v16.0.0 To git@github.com:hashrocket/hr-til - [deleted] v16.0.0

March 18, 2016

Git Log With Authors

In my never-ending quest to better summarize my work at the end of the day using computers, I discovered today the Git --author flag. It works like this: $ glg --since=midnight --author=dev+jwworth+mikechau@hashrocket.com * 4ba91a8 (HEAD, origin/checkout, checkout) Add guard for manual entry of employee discount * 3a4e4c9 Seed a coupon and code and auto-apply in preview * cb1adee Add discount ... The alias glg is discussed here. I use this when multiple developers or teams are committing throughout the day to the same repository, to disambiguate our work from others. Ready to paste into your billing software of choice.

February 25, 2016

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.