How do I find the version of Git repo

14,103

Solution 1

You can use the more common git log -1 or the less used git rev-parse HEAD

Solution 2

If you have not pushed yes, you can check the version of origin/master, or of FETCH_HEAD (see FETCH_HEAD)

cd /path/to/your/local/cloned/repo
git rev-parse origin/master
git rev-parse FETCH_HEAD

That will give you the commit ID (SHA1) of what was last fetched.

Share:
14,103
yolo
Author by

yolo

Updated on June 04, 2022

Comments

  • yolo
    yolo almost 2 years

    I cloned a git repository yesterday and am using it in Ubuntu. I need to find the version of that cloned repository I am using. What is the command for that?

  • yolo
    yolo almost 6 years
    Thanks for the answer. But I get this output: user@lappy:~$ git rev-parse fatal: not a git repository (or any of the parent directories): .git user@lappy:~$ user@lappy:~$ 17 17: command not found user@lappy:~$ 191 191: command not found user@lappy:~$ user@lappy:~$ 37 37: command not found user@lappy:~$ user@lappy:~$ mjkaufer/Messer bash: mjkaufer/Messer: No such file or directory user@lappy:~$ As we see, it says its not a git repo at all. But it is! The repo: github.com/mjkaufer/Messer/issues/63
  • VonC
    VonC almost 6 years
    @shanmuganathan Yes, I have edited the answer: you need to execute that command in the root folder of your cloned repository. And ~ ($HOME) should not be a Git repository. One of your subfolder should be a Git repository: git clone /url/to/repo would create a repo subfolder.
  • yolo
    yolo almost 6 years
    "git clone /url/to/repo would create a repo subfolder." I already did that while cloning the repo
  • VonC
    VonC almost 6 years
    @shanmuganathan Do you remember in which folder (presumably your home directory) you were when you typed git clone /url/to/remote/repo? That command will have created a subfolder, by default named after the repository name. Do a cd repo and you would be in that repository folder.
  • VonC
    VonC almost 6 years
    @shanmuganathan " I already did that while cloning the repo": yes, now you need to go in that repository, with a cd name-of-your-repository
  • yolo
    yolo almost 6 years
    I got it. Thanks.