Bella
Bella

Reputation: 1017

Git - how to get the local changes instead of the remote

I'm new with git, and I made some changes to my script, committed and pushed them to my bitbucket account. When I tried to Upload the newer script version to the server, I got the following error:

error: Your local changes to the following files would be overwritten by merge:
web_app.py
Please, commit your changes or stash them before you can merge.
Aborting

Can anyone tell me how to run-down the version on the server, and get the version I fixed on my bitbucket?

So far I've tried:git reset myfile.py and then git pull but, I got the same error

Upvotes: 1

Views: 85

Answers (1)

Fantastic Mr Fox
Fantastic Mr Fox

Reputation: 33864

Remove local modifications

You want git checkout . to remove local modifications and git pull to pull down the new modifications.

Be aware that this will remove all local modifications, so check this if you want to just do 1 file:

Undo working copy modifications of one file in Git?

Save and re-apply local modifications

If you want to save the local modifications, but pull down the changes you can do:

git stash save // To save the local mods in the stash
git pull // To pull down remote mods
git stash pop // To put back the local modifications

Be aware that if you have changed the same lines in the file you may need to resolve conflicts.

Upvotes: 4

Related Questions