This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the SHA of some branch. There must be a better way to do this. | |
git log -1 --pretty=oneline origin/somebranch | sed -E "s/^([^[:space:]]+).*/\1/" |
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.
3 comments:
Hi, I didn't get that command to work on my mac, but there's an easier way:
git log -1 --pretty=format:%H
/Markus
Markus - odd that didn't work for you. I heard the same from someone else commenting on the gist at https://gist.github.com/374977
I've been using it in a script that runs on Linux and OS X for months and just tried it again and it works fine...
However, I think your way wins. That looks like the way it was meant to be done.
rev-parse offers yet another, even simpler way:
git rev-parse $branch
This is the simplest use of rev-parse.
Post a Comment