开发者

Git pulls without normal merge conflicts

开发者 https://www.devze.com 2023-01-07 21:40 出处:网络
I\'m fairly new to Git, and have been working with it for only 3 months.We previously migrated our repositories from SVN.

I'm fairly new to Git, and have been working with it for only 3 months. We previously migrated our repositories from SVN.

I'd like to be able to merge changes from the master into my dev branch without getting "normal merge" conflicts that require "git mergetool", just so I can inspect a change that could have been merged without special notification.

It may just be my previous SVN background, and an expectation that does not carry to Git, but I remember in SVN that I could merge a change from one branch to another, and it only required special attention if there was actually a merge conflict.

In Git, I'm finding I have to do "git mergetool" because any changes in the master always seem to result in a normal merge conflict, even though t开发者_Go百科here are no actual merge conflicts.

Currently, I pull changes from the master, and merge into the dev branch as follows:

$ git checkout master
$ git pull
$ git checkout dev
$ git merge master
... [do normal merge conflict thing]
$ git -a commit # though usually this is done via the gui, so I'm not sure of the exact command
$ git push

Am I doing something wrong, or missing a config for merges that would be relatively straight forward in SVN, or are my expectations not appropriate for Git?


What you're doing looks like it should work fine. I'm guessing it's somewhere else in the process causing the problem. Having a better idea of what you do to get changes into the master branch might help. Are you doing anything like in the master branch merging from dev but selectively backing out some changes?


i think you want to rebase instead of merge.

i always do

#on my master
git fetch origin
git rebase origin/master
git checkout mybranch
git rebase master

if you have any uncommitted changes you want to preserve, you can stash them and then after pop them. its been a while since ive used git (man i miss it) but that routine worked well for me


You are not doing anything wrong. This is a perfectly normal work flow, perhaps even the most common. If you constantly get merge conflicts you need to take a look and examine WHY they happen all the time.

For example it might be the case that you have mixed versions of unix and windows line endings, e.g. '\n' or '\r\n'. It might also be the case that you do in fact have normal merge conflicts and if that's the case, you would have the same problem on any other version control system.

Cheers

0

精彩评论

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

关注公众号