On Thu, May 07, 2020 at 02:27:56PM +0530, Kunal Chauhan wrote:

[...]
> I went through the git doc url but still it is not clear to me* how
> can i search particular commit exist or not ?*

Depends on how you define "particular commit" and how do you define
"exists".

If you know it's SHA-1 name (its "hash", such as
"ab49e09032ad1fd40f0123f58a3d6c90ea451ec2"), the answer is to run

  git cat-file -t <sha1_name>

This command either outputs a single word describing the type of the
object identified by <sha1_name>, and exits successfully, or prints out
a "not found" error message and exits with the non-zero error code.

Note that this command is quite a low-level one, and it searches the
whole local Git repository it was run on - paying no attention to
branches, tags etc. It just traverses through everything the repository
contains and searches for the specified name.

Note that if you merely want to see whether a commit exists "as a user",
just run

  git show <sha1_name>

This command will either format you the message describing the commit
and the diff of its changes or exit with an error message.


If by saying "particular commit" you mean something else - such as a
commit which introduced or removed a particular line of text, or a
commit whose commit message contains certain text, the answers will be
different, and you need to narrow your question down.


If by "exist" you mean something less broad - like whether a commit
exists on a particular branch or is reachable via a particular tag, -
the answers, again, will be different.

[...]

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/git-users/20200507100117.lq4gnccx3ppjfqpv%40carbon.

Reply via email to