Git – Force Overwrite of Untracked Working Tree Files

Sometimes we got error ” error: Your local changes to the following files would be overwritten by checkout: ” while we run ” git pull ” or ” git checkout branch “. In that case, if we want to overwrite these files. So what do we do? We use the following:

git fetch –all
git reset –hard origin/master

This grabs the latest repository files without merging and resets the master branch and overwrites the modified ones.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s