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)
write your merge message. press esc (escape) write :wq (write & quit)
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With