Reputation: 1322
Does Git have any command equivalent to Mercurial's "hg id"? I.e. a command that prints the parent commit's hash and a plus sign if there are changes in the working directory?
Upvotes: 21
Views: 4295
Reputation: 370
git ls-remote REPOSITORY BRANCH
will show the hash of the head of a given branch.
https://git-scm.com/docs/git-ls-remote.html
Upvotes: 0
Reputation: 2830
This command is equivalent to hg id --id
:
git describe --abbrev=12 --always --dirty=+
Upvotes: 14
Reputation: 129614
git log -1 HEAD^
will show you the whole commit including the SHA-1
If it's a merge, you can see the second parent's commit info with
git log -1 HEAD^2
If you have an octopus merge with more than 2 parents you can put any number in the tree-ish spec:
git log -1 HEAD^5
... to see the 5th parent's commit info
the -1
just limits the log output to one commit. You don't want the lineage of that commit reported.
Upvotes: 3
Reputation: 13067
git status
would show the changes in the working directory, and the branch info.
I guess git log
can be used to see the last few commits.
Upvotes: 0
Reputation: 993611
I don't think there's a command exactly like that, but you can use:
git status --porcelain
which outputs a machine-readable listing of changed files in the repository. You can look for anything in the first column that is not ?
to indicate a changed file.
Upvotes: 1