Canonicalize current Git commit, using it as a reference point for forked repos
I am deploying several websites with Git using a common code base. Is it possible to run
git fetch on a server and then a certain command to represent
HEAD in relative terms from
For example, I want to know if the server is running
master/branch^4. Of course there could be ambiguity… maybe
master/branch^2… here I want
master/HEAD^6, but there is no preference for other ambiguities.
Also, I want to know if the server is “clean” (no uncommitted files and no commits on top of e.g.
master/branch^4) or “dirty”.
Bonus points if I can easily query this by accessing files in
$GIT_DIR rather than using the
2 Solutions collect form web for “Canonicalize current Git commit, using it as a reference point for forked repos”
It sounds like you are looking for the
git describe command. This command is most useful if you use tags, and gives you a short human readable description of how much the current branch has changed since the most recent tag.
You could do something like:
git log HEAD..origin/master --oneline | wc
git log --oneline will give you details about each commit between
[start]..[end] and wc will give you a count