Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git pull options to prevent merge conflicts

Tags:

git

git-merge

Is there an option(s) when doing git pull that will not allow any possibility of a merge conflict? I've looked at the merge strategies but none seem to meet this description. I'm looking for an option like git pull --quit_if_possible_merge

Basically, want a command for pulling to production site without any risk of a merge conflict which would temporarily bring the site down while we resolve it.

like image 790
emersonthis Avatar asked Apr 12 '13 20:04

emersonthis


3 Answers

What about:

git pull --ff-only 

If what has been said in the other answers is true, this should have exactly the desired effect. No?

The --ff-only flag stands for "fast-forward" which is how Git refers to a situation in which one of the merging branches contains all of the commits of the other ( a strict superset ). This is special because it means no merge conflicts are possible. The commit so on the branch that is ahead simply get added to other branch and everyone is happy.

like image 121
emersonthis Avatar answered Oct 25 '22 19:10

emersonthis


I don't think there is any such flag. If something conflicts it conflicts and needs to be handled. But there is a merge strategy that guarantees no merge conflicts: don't modify or commit anything on the production site.

If nothing is committed on the production site then there is nothing to conflict with it. Do all merging on the production branch on your local machine and resolve all merge conflict there before pulling from the production site.

like image 35
slebetman Avatar answered Oct 25 '22 19:10

slebetman


As already stated by others: you only get merge conflicts if you committed anything in the local repository. If you don't you will not get any merge conflicts.

If you did not commit anything, but you were working inside you local git repository, i.e. you changed files or created new ones, a git pull will still get you in trouble, when it needs to update your modified files. - Hence, do not work inside your local repository directly and you are fine.

Next if you insist on working inside your local repository and think of a git pull to update your files. You have to decide what to shall happen with your modified files. If you simply want to abandon all local changes and just get the files as they are in the remote repository you can do a git fetch;git reset --hard @{u}.

like image 20
michas Avatar answered Oct 25 '22 20:10

michas