Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find the branch for a commitId in git?

Tags:

git

lets say I have a commit Id "0678dd19c498ede50e7714505eb5af3a5494beef" I tried "git log" command, which prints,

$git log --full-history   1c57338cd62ee1a83df57d2c37ce1f3fa17bee17
commit 1c57338cd62ee1a83df57d2c37ce1f3fa17bee17
Author: [email protected]
Date:   Thu Feb 3 15:39:33 2011 -0800

Updated ejo syntax

commit 8fb7a6b3e44a020e4e495fd1c9a9976c8675c339
Author: [email protected]
Date:   Thu Feb 3 14:49:19 2011 -0800

Added a sample controller

commit 628788eb81c365a88ab435ffa62978077065f72c
Author: [email protected]
Date:   Wed Feb 2 11:33:41 2011 -0800

Test checkin

Is there anyway to print the branch on which this commit is made?

like image 659
Nambi Avatar asked Nov 27 '12 22:11

Nambi


People also ask

What is the commit ID in git?

Commit IDs are unique SHA-1 hashes that are created whenever a new commit is recorded. If you specify a commit ID when you add a repository, Domino will always pull the state of the repository specified by that commit in a detached HEAD state.

How do you get details of a commit?

`git log` command is used to view the commit history and display the necessary information of the git repository. This command displays the latest git commits information in chronological order, and the last commit will be displayed first.

How do you find all commits in a branch?

On GitHub.com, you can access your project history by selecting the commit button from the code tab on your project. Locally, you can use git log . The git log command enables you to display a list of all of the commits on your current branch. By default, the git log command presents a lot of information all at once.


1 Answers

The command you want is

git branch --contains <commit>

Note that the commit may be contained in multiple branches.

like image 76
Dylan Tack Avatar answered Sep 27 '22 23:09

Dylan Tack