Is there any way to make a "git pull" without conflicts?

Asked

Viewed 2,327 times

2

After much in the life of programming break the head doing FTP to update the system that is running in production, I decided to adopt as default the use of GIT.

When I have a new update tested, I do a git pull in the production application directory. It’s easier that way, and what I would do with 20 minutes or more do with 2 seconds.

But a concern arose: What if when I give one git pull, der the famous "Merge Conflict" in the archives?

I started searching the Internet if there was any way to make a git pull, forcing to modify the files for the last update, without having "merge Conflicts" problems, but I didn’t find much (maybe because I don’t know what to search in English).

I don’t know if that’s relevant, but obviously, the files in production aren’t altered. Even so, a conflict could not occur precisely in production.

Someone knows a way to make one git pull, but without giving conflict? It is possible this?

2 answers

5


If you always use git pull and make no changes to the repository, will not give conflict; for conflicts can only occur if the git can’t do merge automatic between your local repository and the remote repository. If you never have local changes, it doesn’t need to merge.

But if this problem occurs at another time, follows the answer based on a response from the OS:

If you are ever to discard any change that has been made locally, you should not do pull - pull means to lower the commits remote and merge.
All you need to do is:

# obter o branch padrão remoto (origin)
git fetch
# resetar seu branch atual (master) para o master origin
git reset --hard origin/master
  • 1

    So it is someone who is doing khda and editing the files in production, heheheh. + 1

2

Daniel responded well, if there are no modifications locally, pull will be done without problems but if you have modified something, it is preferable to save the modifications before doing the pull:

  • Saving the modifications: git stash save or git stash
  • git pull
  • Recovering the modifications: git stash apply or git stash pop

Browser other questions tagged

You are not signed in. Login or sign up in order to post.