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 master?

For example, I want to know if the server is running master/HEAD, master/HEAD^2, or master/branch^4. Of course there could be ambiguity… maybe master/HEAD^6 equals master/branch^2… here I want master/HEAD^6, but there is no preference for other ambiguities.

  • Can I push/pull directly from my google drive online?
  • Using git hooks to create a diff report for every file that has changed for the current commit
  • How do i add .gitignore to all branches in repositories in Git?
  • How to name a (no branch)-branch on git
  • GIT : what does mean “to dump”?
  • Searching git commits for a particular change
  • 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 git command.

  • how to get git log -p to show changes in merge commits
  • Git command to programatically add a range of lines of a file to the index?
  • using Git and pushing to production mode (w/ diagram)
  • GitLab: Is there a way to protect a branch from command line?
  • how to create a gist in github that returns json data
  • Is using `git checkout --theirs <filename>` a legitimate way of resolving a merge conflict?
  • 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

    Git Baby is a git and github fan, let's start git clone.