0

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?

3
  • I hope your branches aren't actually called master and master1. That's very confusing. Commented Mar 24, 2015 at 12:37
  • they are not, updated the question Commented Mar 24, 2015 at 12:38
  • You need to give information about your current branch when you are running those commands... Commented Mar 24, 2015 at 12:43

1 Answer 1

1

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 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.