Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the revision hash of the last push to a branch?

Tags:

git

git-branch

  • I am looking for the step by step commands to be run.
  • Assuming that the required branch may not yet be present in my local repository, and my workspace could be pointing to another branch, what set of commands should I run, so that I get only the minimum required data. Should I try to get the log information first, so that I can get the revisions corresponding to a branch?

Or should I do a git fetch of that branch and then get the revisions corresponding to that branch?

like image 227
Sandeepan Nath Avatar asked Dec 09 '25 05:12

Sandeepan Nath


1 Answers

git ls-remote origin master

will get you every ref on on the remote that matches "master", ls-remote is lower level than the ref-naming conventions. Branch refnames are names that start refs/heads/.

You can list any repository's refs directly, try

git ls-remote git://git.kernel.org/pub/scm/git/git.git refs/heads/master

or just leave off the refname pattern for example.

This also works on the current repo, try

git ls-remote .

in the obvious place.

like image 158
jthill Avatar answered Dec 10 '25 20:12

jthill