"Git pull origin master" overwrites existing local file and does not show conflict when it should

Hello all,

I’m new to git. I am learning how git pull works.

I manually edited the readme.md on master on the Github website. Then, I went back to terminal to do a pull,

git pull origin master

I was expecting a conflict, because my local file is not the same as the one on Github website. Instead my local readme.md is overwritten from the website. What am I doing wrong? Does it have to do with my configuration?

Thanks so much!

When you edit files in a repository, you should always commit them before carrying out operations that could potentially override the current status of your local fork or clone (pulling, etc.). If you don’t want to commit your changes, at least stage them, which would prevent Git from overriding them.

Also, remember that git stash is your friend! it allows you to create a copy of your changes (and temporarily hide them) and you can always get them back. You can have multiple stashes, in case you’re unsure which final version of a changes set you’re going to ultimately commit.

A conflict in Git refers only to conflicts between files which are handled by Git — i.e. committed files!