开发者

Merge branch 'user' in git log

开发者 https://www.devze.com 2023-01-19 06:11 出处:网络
I am working in ROR in a Ubuntu machine. I had done some changes in my files and commited it with a msg.

I am working in ROR in a Ubuntu machine. I had done some changes in my files and commited it with a msg.

Now when i checked with the git log thing..

I am getting a new msg rite above my commited message as Merge Branch 'myname' .. Why is it so coming like this ?

Please give suggestions..

EDIT :

D开发者_Python百科ate: Mon Oct 11 11:42:29 2010 +0530

Merge branch 'aruna'


You shouldn't worry about git "merge commits". The merge commit just contains the differences between your local version of the branch and the remote version of the branch. (hence why they appear when you pull and there were any changes).

Rebasing, exactly as suggested in pawien's answer is a good way to avoid those, but only if you know what you are doing. Rebasing should only ever be used in a local feature branch (a branch that you never push), because it re-writes all the commits that have been commited to the feature branch. rebasing a branch that has other peoples commits in it can accidentally delete commit history if you don't know what you're doing.


This is a git question and is not related to Rails.

So - it is quite normal in git and it will happen in situation like this

               - aruna: X -> Y 
              /
master: A -> B -> C -> D .....

when you merge aruna with master (either by doing merge aruna on the master branch or just by pulling [pull is "two in one" command - it makes fetch & merge]) you will get new "merge" node that is the merge of both branches (nodes C, D & X, Y)

As you are asking I bet that you don't like it. So the possible solution is to rebase the aruna branch instead of merge. For example:

# normally commit everything in your aruna branch
git checkout aruna
git add ... 
git commit -m "..." ...

git checkout master
git pull # it will just fetch as there is nothing to be merged
git checkout aruna
git rebase master # and solve possible conflicts
git checkout master
git merge aruna # it will *not* make the "merge node"
git push

EDIT: As others mentioned - the rebasing is really no option if you already pushed the branch or you have other people who pulled your branch.

But still - rebasing is an option if you are merging your local private branch. Which is a quite common scenario. And as your branch is named "aruna" (your name) I thought that's the case. But as I think about it again there is no reason to think so :-)

While rebasing (local feature branch), you will lost some part of history that says that you did your commits in parallel. But the trade-off is that you will have simpler narrow tree.

0

精彩评论

暂无评论...
验证码 换一张
取 消