Reputation: 1430
I am getting something unexpected happening in the git tree. I have created a branch off of master, however while I am performing commits on the new branch it appears as though these are taking place in the same code line as master...
As you can see, on the very left hand side is the code line for master (dark blue) and right at the top we can see Sprint_15 which is a branch taken from master that appears to have commits on the same line... I am not sure why this is taking place. I would expect to see the code diverge into a new line since features are being merged into Sprint_15 and not master...
My thought is that by merging Sprint_14 and Sprint_15 together this has done something funky to the history but I am not sure why.
I am still fairly new to git so some of its underpinnings still confuse me.
Upvotes: 9
Views: 3855
Reputation: 1693
It seems that you are a bit mistaken on how git works (which is normal because you said you are new to git)
Each branch does not necessarily get it's own line. If your branch Sprint_15
has it's base as master
and Sprint_15
is any number of commits ahead of master
then they will share the same line. As soon as master
gets a new commit then I think you will see what you expect.
You can test this in a separate git repo like this.
$ mkdir testing && cd testing
$ git init # should put you on master branch by default
$ touch testFile.txt
$ git add -A
$ git commit -m "initial commit"
$ git branch newBranch
$ git checkout newBranch # switch from master to newBranch
### modify the testFile.txt in some way and then...
$ git add -A
$ git commit -m "first commit on newBranch"
Now if you use the same tool to look at your repo, you should see only a single line, like this:
Now go back to the master branch and make another commit:
$ git checkout master
### make another change to testFile.txt
$ git add -A
$ git commit -m "second commit on master"
Now you will see each branch having it's own line like you were expecting, like this:
Upvotes: 15
Reputation: 521093
This is a speculation, but I suggest that the reason your current feature branch appears to be on the same line as master
is because currently that branch is directly ahead of master
by some number of commits. To test this, try doing a pull on the latest master
branch. If this changes your configuration such that Sprint_15
appears as a separate line, then my hunch was correct.
In any case, you can always check such things directly from the Git bash if you are in doubt.
Upvotes: 0