GIT-PROTIP: Copy Most Recent Commit Hash

I often have the need to get the latest commit hash on my current branch so I can reference it on GitHub in response to a comment on a pull request. My workflow was always:

  1. Make code changes
  2. Commit changes
  3. Run git log
  4. Copy latest commit hash
  5. Run git push
  6. Paste the commit hash into GitHub

I decided to make this workflow a little easier by adding an alias for the following command which cuts out steps 3 and 4:

I aliased this command to glc and now I just run that alias and the latest commit hash is copied to my clipboard and ready to be pasted into GitHub.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s