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.
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.
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.
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}
.
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