Reputation: 2563
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?
Upvotes: 0
Views: 1551
Reputation: 7405
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
Upvotes: 1