user482594
user482594

Reputation: 17476

Is there any git command to display the information about local branch?

For example, if I am branch A, and created new branch B with the command

git checkout -b B

is there any way that sometimes later I can find out where branch B copied from?? (A) in this case

Upvotes: 0

Views: 100

Answers (3)

Andy
Andy

Reputation: 46324

You could do git merge-base branchX branchY that will give you the common parent. That will tell you when it split off the branch, but there is no way to tell who it split off of.

Upvotes: 4

Sailesh
Sailesh

Reputation: 26197

Have you tried gitk?

Displays changes in a repository or a selected set of commits. This includes visualizing the commit graph, showing information related to each commit, and the files in the trees of each revision.

The various branches and tags are highlighted in the tree.

Upvotes: 1

avh4
avh4

Reputation: 2655

There no tracking of which branch was created from which, and the commits that each branch point to could change at any time.

But this might do what you need:

git branch --merged B

That will show the list of all branches that are ancestors of branch B. So if you are on branch B, it will show branch A until there are commits made to A that fork it off--then it will no longer show A unless you merge A back into B, then it will show A again.

Upvotes: 0

Related Questions