user7341673
user7341673

Reputation:

Rails 5 git pull giving error

Hey I am trying to pull my changes to server I am using ubuntu server. When I am trying to run git pull I am getting this error:

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

I have tried git reset --hard and then pull again I am getting this error When I am trying to remove file Gemfile.lock using rm -rf Gemfile.lock it is not removing the file. I don't know how to make git pull work.

Upvotes: 0

Views: 74

Answers (2)

Pradeep Agrawal
Pradeep Agrawal

Reputation: 346

Follow these commands and you will be good to go

git stash
git pull origin <branch_name>
git stash pop

This will do the job. Let me know if you still facing the issue.

Upvotes: 1

letthefireflieslive
letthefireflieslive

Reputation: 12664

Option 1: if you want to set aside the changes you have made from previous commit

git stash
git pull

if you want to have the state prior to pulling (may cause merge conflict), proceed to:

git stash apply

Option 2: if you want to apply the changes you've made from previous commit

git commit -m "I edited this blahblah file"
git pull

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

is because you have changes in the tracked files that is not committed yet. So git wants you to commit it first (if you want to keep your changes from previous commit) or put your changes to a temporary location (stash) so that the state will go back to previous commit

Upvotes: 0

Related Questions