简体   繁体   中英

git stash merge conflict

so I have 2 branches master and feature-example . I have a code change to master which I don't want to push to the repository. There's a commit to feature-example which I want to pull, So I did

git stash
git pull 

and then

git checkout feature-example

now I made some changes to feature-example branch which I don't want to push, I want to checkout to master branch. so I am trying to do

git stash pop

It gives me conflict. And when I am trying to do

git checkout master 

It says,

app/assets/javascripts/abc.js: needs merge error: you need to resolve your current index first

So I do not want my changes on feature-example to be pushed, I want it to be the old commit and I want to checkout to master branch.

PS: I do not want any commit to be made on the repo, not even the merge one.

Pretty weirdly asked but any help on this?

To discard changes in a specific file you can use git checkout -- <file> :

I think this would solve your problem:

git checkout -- abc.js

Or you can resolve the conflict, commit the changes and reset head afterwards. The last commit will be removed:

A-B-C
    ^
  feature-example

git reset --hard HEAD~1

A-B
  ^
  feature-example

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM