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?
Asked
Active
Viewed 2.4k times
2 Answers
6
You can use the more common git log -1
or the less used git rev-parse HEAD

Sauhard Sharma
- 405
- 1
- 3
- 13

Neeraj Bansal
- 380
- 7
- 23
1
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.

VonC
- 1,262,500
- 529
- 4,410
- 5,250
-
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: https://github.com/mjkaufer/Messer/issues/63 – yolo Jun 03 '18 at 06:13
-
1@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. – VonC Jun 03 '18 at 06:14
-
"git clone /url/to/repo would create a repo subfolder." I already did that while cloning the repo – yolo Jun 03 '18 at 06:18
-
@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 Jun 03 '18 at 06:19
-
1@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` – VonC Jun 03 '18 at 06:19
-