Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts

Thursday, April 22, 2010

Find the SHA1 of the latest commit in a git branch

Here's a way to get the SHA1 of the last commit in a given branch in a way that can be used in a script easily. For humans `git log branchname` is probably fine - just read the first line. For a shell script that wants to get that value into a variable, here's a quick way to do that:




Seems like there ought to be an easier way...but not that I could find in less time than it took to write this command.