senty
senty

Reputation: 12847

Get commit id of a directory

I have a directory on the production server which was deployed some time ago. On the development server, I developed much more and pushed it to git.

Is there a way to check the current commit id of the directory on the production server, just to make sure (through cli)?

Something like, I run: git check current-commit-id on the directory (on production server) so I get the current commit id of that directory. And if something bad happens, I can go back to that working version

Update: Using git rev-parse HEAD, it gives me "777dc337c212095cfda279bef882d3266b0f123"; instead I want the one that looks like "9be5922"

Upvotes: 7

Views: 9314

Answers (3)

LightCC
LightCC

Reputation: 11659

For CLI, use:

git log HEAD~2..HEAD

will show you the last few commits, including their full SHA-1 hashes (i.e. commit ID). You can change the ~2 to another number to see a specific number of commits.

And using:

git log

will list all of them, for the current branch. If that is master, the last entry should be the first commit when you started the repo.


Note: Edited to remove superfluous items resolving with the OP what the real question was (see comments)

Upvotes: -2

James Green
James Green

Reputation: 313

Building on @Schlacki answer

If you need the full commit hash rather than the short hash you can do this.

git log --pretty=tformat:"%H" -n1 .

Not capital H rather than lower case h

Upvotes: 2

Schlacki
Schlacki

Reputation: 193

This is the command you were looking for:

git log --pretty=tformat:"%h" -n1 .

Note: "." is the current directory, you may want to specify a specific directory instead.

Upvotes: 13

Related Questions