Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Unable to understand why branch (topic) commits/merges are happening on the master branch

Note: I am not sure whether this has been already asked, as I can't find any question fitting to my context(or I am unable to understand the existing questions' contexts')

I am loving Git these days. Especially, the topic branches. I am working on a small code sharing application. And I have got (local)branches like "master", "authentication", "bookmarks", "comments", "nose" etc...

My (intended)workflow goes something like this: Create a topic branch ==> Work on the topic branch ==> Commit the files to the branch ==> Merge the topic branch changes to the "master" branch. (And later delete the topic branch)

I tried doing the same for a couple of branches. It worked fine. But later when I checked the git graph, even if I followed the same workflow, all the chances were happening on the "master". No tree lines diverging and converging! It shows one singe line with multiple commits from then. I am not sure why? I am of the impression, I screwed something with HEAD pointer?

To give a practical view, here is my git graph: http://github.com/none-da/zeshare/network

Here are the commands I used:

>> git branch authentication_feature
>> git checkout authentication_feature
>> # I work with all the files here in "authentication_feature" branch
>> git commit -m "Authentication_feature is up" # commiting to the branch
>> git branch # just to confirm, which branch I am working on
>> git checkout master # trying to shift to master branch
>> git merge --no-commit authentication_feature # I merge in two steps. This is step 1
>> git status;git add; git commit -m "Authentication_feature" merged to "master". # This is the step 2
>> git log --graph --pretty=oneline # confirming the graph
>> git push origin master # pushing to the remote server(github)
like image 261
None-da Avatar asked Feb 04 '10 02:02

None-da


People also ask

How do I stop git from merging messages?

write your merge message. press esc (escape) write :wq (write & quit)


1 Answers

I bet you're looking for the --no-ff switch on git merge. By default, merge will just update the HEAD to the tip of the new branch, if there's no intervening commit.

If you want to leave the merge commit around to help with grouping your commits, pass --no-ff.

like image 159
John Stoneham Avatar answered Oct 21 '22 00:10

John Stoneham