Reputation: 1134
How can I get some sort of ID in a Git repository that can tell me the latest commit/push to the repository?
I've come up with the following so far; I'd like to know if this would work for the description below, or if I need something else:
rev=`git log --max-count=1 --pretty=format:%H`
I currently have a backup script for Subversion that works something like this:
svnlook youngest /path/to/repo
.dumpFile=${base}-${rev}.svndump
.I'd like a Git full backup script that works the same way so, if I backup a rather large repo every night or every week, and there hasn't been any activity in three months across every branch, every tag, every property, then I'm not wasting additional disk space nor time repeatedly dumping the same data over and over again.
Upvotes: 3
Views: 155
Reputation: 124646
A simpler way is using git rev-list
:
# latest commit in current branch
git rev-list -n1 HEAD
# latest commit in all branches
git rev-list -n1 --all
Upvotes: 1