I'm working with git and i want to disable git automatic merge on git pull because sometimes it results of code errors since git merges based on line comparison .Is it possible to force GIT to always launch manual merge instead of automatic merge on git pull, other words disable git automatic merge.
-
6Possible duplicate of How to prevent an automerge using git?Phiter– Phiter2017-12-18 15:58:10 +00:00Commented Dec 18, 2017 at 15:58
-
already gone through this post , it's not what i'm asking , i'm asking if it's possible to bypass for good the automatic git merge process, the answer provided in the post restrict you to always go through git difftool before doing a git pull, whereas what i need is to disable git automatic merge.AILY– AILY2017-12-18 16:19:00 +00:00Commented Dec 18, 2017 at 16:19
-
No, but I'm curious why you would want to.Edward Thomson– Edward Thomson2017-12-18 16:58:38 +00:00Commented Dec 18, 2017 at 16:58
-
Sometimes merges cause errors, and to have full control of code i need to set a way to make git always run manual merge for developersAILY– AILY2017-12-18 17:03:46 +00:00Commented Dec 18, 2017 at 17:03
-
1Do you understand what a merge is?evolutionxbox– evolutionxbox2017-12-19 10:57:15 +00:00Commented Dec 19, 2017 at 10:57
3 Answers
My guess on what you actually want here is to disable merge when there is no possibility to fast forward you current branch to the upstream branch.
By default git behavior is that when your local branch is different from the upstream git pull runs merge. Merge in its turn will attempt to fast forward the branch and if it fails (this happens if your local branch is not a direct ancestor of the upstream branch position) it then tries merging it the "usual" way. In this case merge may result in merge conflicts that you'll have to resolve. This is I think is what you mention in your question and what you want to stop happening.
To prevent this situation you can configure git pull to only perform merge if fast forward is possible. You can do this by specifying --ff-only to git pull invocation:
git pull --ff-only
Or you can make this the default behavior for git pull by using git config:
git config --global pull.ff only
Comments
From git pull manpage:
git pull is shorthand for git fetch followed by git merge FETCH_HEAD.
So git fetch may be what you need.
Comments
There is no such thing like "manual merge".
However, if you want to inspect (and modify) the result of the merge before committing it, you can add the --no-commit command line flag to the git pull command.
Git still does the merge but you can review and correct it (if needed). Then, when you are satisfied how the merged code looks like you can run git commit to complete the merge (and the pull).