Is there any way to do a git pull without conflicts?

2

After a lot of programming in my life, breaking my head doing FTP to update the system that is running in production, I decided to default to GIT .

When I have a new update tested, I make a git pull in the directory of the application in production. It gets easier this way, and what I would do with 20 minutes or more will do with 2 seconds.

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

I started to search the internet if there was any way to make a git pull , forcing to modify the files for the last update, without having problems of "merge conflicts", but did not find much (perhaps for not knowing what search in English).

I do not know if this is relevant, but obviously the files in production are not changed. Even so, you could not have a conflict right in production.

Does anyone know a way to git pull , but without conflict? Is that possible?

    
asked by anonymous 02.06.2016 / 20:24

2 answers

5

If you always use git pull and do not make any changes to the repository, it will not conflict; because conflicts can only occur if git is unable to% automatic% between its local repository and the remote repository. If you never have local changes, it does not need merge.

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

If you are always discarding any changes that were made locally, you should not do merge - pull means to download remote commits and merge. All you have 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
    
02.06.2016 / 20:34
1

Daniel responded well, if you do not have modifications locally, pull will be done without problems but if you have modified something, it is preferable that the modifications be saved before doing pull :

  • Saving changes: git stash save or git stash
  • git pull
  • Retrieving changes: git stash apply or git stash pop
02.06.2016 / 21:37