This article is about how to force
git pull to overwrite local files.
Sometimes when we do a pull request on a particular branch we get error like:
error: Untracked working tree file 'images/icon.png' would be overwritten by merge
These error occurs because we have local changes that will overwritten when we will do a pull request on the same branch.
For safety reason, git wont allow to overwrite the changes or do a
force pull over it.
However, we can follow certain steps which will help accomplished our goal of doing a
Follow the steps below to do a force git pull to overwrite local changes.
Step 1 : Run a fetch to update all branches in your repository. It will get the latest files from the remote repository without merging them.
git fetch --all
Step 2 : Now we have to clean or stash up our file changes. We can do it in two ways:
git stash -u // OR git stash --all
git reset --hard origin/master //OR git reset --hard origin/<branch_name>
And if you have any untracked files, you just have to clean those files the local branch.
git clean -fd //OR git clean -f -d
Step 3 : Now as you have clean all the untracked files / new files. you just have to a git pull again.
git pull origin master
That's it now you can pull your changes again and code on your project. 🧑🏻💻
This article is about how to solve npm warn package.json: no repository field in our nodejs applications.
This article is about how to fix npm err! missing script start error in nodejs application.