Hard resetting the current branch to fix failing pull because of package-lock.json change

Views: 278   

package-lock.json may get updated when you do npm install so this may look different from the remote. In those cases when you try to pull you will get the following error

error: Your local changes to the following files would be overwritten by merge:

Ideally in these cases you want to ignore all your local changes instead commit or stash> You can do this by running the following command

$ git reset --hard

Once this is done, you can now perform the pull operation. You can see them in following logs

$:~/githome/api$ git reset --hard
HEAD is now at ac79c61 last commit message foo bar
$:~/githome/api$ git pull
Updating ac79c61..784b539
 index.js                    |  1 +
 package-lock.json           | 11 +++++++++++
 package.json                |  1 +
 public/js/user-controllers.js | 21 ++++++++++++++++-----
 routes/email.js             | 27 +++++++++++++++++++++++++++
 routes/users.js             | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 115 insertions(+), 5 deletions(-)
 create mode 100644 routes/email.js
On By