Git chart not showing a branch

As it happened, when I create a new branch and make it, I do not see its branches on my chart.

Here is the code I'm doing:

git init git add . git commit -a ... other commits in here git checkout -b mynewbranch git add . git commit -a git checkout master git merge mynewbranch git add . git commit -a 

This is what I expect to see in my mind when I do git log -graph

 * 47926e1 This is a commit back on master \ * f3dc827 How come i am not seeing a branch in my tree * 1cd3018 This should be on my new branch / * 47f3716 This is my third commit * 878b018 This is my second commit * 2db9f83 Initial commit 

But I see this:

 * 47926e1 This is a commit back on master * f3dc827 How come i am not seeing a branch in my tree * 1cd3018 This should be on my new branch * 47f3716 This is my third commit * 878b018 This is my second commit * 2db9f83 Initial commit 

I do not understand something?

+4
source share
1 answer

If there are no commits in the process of working on mynewbranch, and your story will look like you showed. In this case, the actual merger is not required; the merged master is identical to the tip of mynewbranch. If so, git will (by default) perform the so-called quick switch; the branch branch master is simply updated to be the same fix as the tip of your merge. This usually leads to a simpler transaction history, which is easier to work with, especially if the work also happens in remote repositories.

If you want the merge to be written as a merge in git, you can use the -no-ff option on git merge.

In git, it is generally considered good practice to avoid merging where possible.

+4
source

All Articles