I have changed a file that my friend is working at the same time. I did some changes and now I want to push it but it says I should pull first. When I git pull
, it says:
error: Your local changes to the following files would be overwritten by merge: Please, commit your changes or stash them before you can merge.
Aborting
How can I merge the file? If I do it would the file from my friend completely change? I am sure he has added some stuff and I have added my stuff. How will our changes be handled?
One approach is to commit that file first then pull.
git add filename
git commit
//enter your commit message and save
git pull
Another approach is stash your changes then pull. Then apply stash.
git stash
git pull
git stash apply stash@{0}