says I'm on a branch called master
, then I do git checkout -b myBranch
, then I branch out from master. But later on, how can I track or know myBranch is from master? anyway I can know it?

- 291
- 2
- 15
-
1In one sense all branches come from master. In another sense branches don’t come from anywhere and the question makes no sense. :) The simplest thing is usually to look at a picture of the history (gitk or whatever). – matt Oct 01 '20 at 04:31
-
2What you are asking for is not something that git keeps track of.... you might get a good guess by checking the history of the branches, but it won't be bullet proof because branches are just pointers to revisions that can be moved around at will in any direction. – eftshift0 Oct 01 '20 at 05:04
1 Answers
There are many ways, here are some of them
Option 1: Built-in UI tool
Git usually comes with a tool called gitk
. Its a graphical tool that shows you the history of commits on your branch and among other things shows the point where your branch "came out" from master
Option 2: Command line
If you prefer the command line approach,git log --graph
this comes with a lot of options (flags) and can be really powerful if you tweak it enough.
An Example:
Lets say I've done a couple of commits on master branch (added a.txt and b.txt) then checked out branch1
and made a commit that adds c.txt. Then I can use :
git log --graph --oneline --decorate --all
This prints something like this:
* 0f9bb2a (HEAD -> branch1) Added c.txt
* 804474d (master) Added b.txt
* 9ee42ad Initial commit: added a.txt
So its clear that your branch1
came from master (see the second line)
Option 3: IDE and third-party tools
Use IDE - nowadays ides can be really powerful when showing the history of commits, branches "relations", etc. For example in the Java world both "dominating" IDEs (IntelliJ IDEA and Eclipse) have such a functionality.

- 39,963
- 4
- 57
- 97