Chris Chris - 9 months ago 91
Git Question

Git/Sourcetree basic branching and merging

Newbie question alert!!! I am just starting to get into using Git, and particularly Sourcetree which seems like a good application for visualizing it. On my first test it went along pretty well, branching and merging (see the top diagram). I know this structure means I'm using the development and master branch the wrong way round, but that's fine because at least it worked.

On my second try though, I couldn't seem to visualise any branches, even though work was being done in both of them they seem to appear in one single branch (with a '7 ahead' note), and when I try and merge nothing seems to happen. Hopefully the second screenshot is enough for someone to tell me what is happening here? If not I will try and give some more info.

I'm just playing around at the moment, so still getting to grips with proper workflow, just trying to get the basic branching and merging actions to take place in a consistent manner through Sourcetree. Any help will be appreciated.

enter image description here

Answer Source

In the second picture there are branches. Locally you have 2 branches, master & develop. Both branches are resting at the same commit though. If you want to 'see branches' as in the first picture you can make a commit on develop, however the graph will still apear to be linear. You'll be able to merge develop into master at that point if you want.

If you want to see the graph diverge, try putting a commit on master as well. Then you will start to see something more like the first picture.

To get an idea of how git works with a visualization program like this, I suggest you do actions like I suggested above, and take a look at the graph at each intermediate step.