Reputation: 1906
I am getting this error while running git command git pull origin master into my server repository.
please, commit your changes or stash them before you can merge. aborting in
run of pull command
i am facing this many time when run this. For solve this problem i tried git reset --hard. but there any other solution for this.
Actually problem is that i made some changes before pull and now master has some change in same file in which i am working. so i do want want to push current change and accept new changes that will come from Master Branch or Other Branch.
Upvotes: 1
Views: 9191
Reputation: 1906
Yes git git stash
is an option but sometime we have to keep current changes then we can do one thing we can make new Temporary Branch from current branch and then stash old branch. so by this way we can keep current code copy into temporary branch and accept new commit from new branch.
For this we have to create new branch.
git checkout -b <temporary_branch_name>
git merge <current_branch> // optional. because git checkout automatally do it.
git checkout <old branch name > // come back on disputed branch
git stash // remove current changes.
git pull origin <branch_name> // for accept new changes.
Upvotes: 0
Reputation: 52516
My experience is, when error or warring happen, follow Git client instruction.
commit your changes or stash them before you can merge.
therefore,
(1) git stash
(2) Merge
(3) git stash pop
Upvotes: 1