Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git branch is still on same line as master

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...

enter image description here

enter image description here

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.

like image 810
Matthew Pigram Avatar asked Jun 05 '17 05:06

Matthew Pigram


1 Answers

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: same line

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:enter image description here

like image 186
BigHeadCreations Avatar answered Oct 11 '22 05:10

BigHeadCreations