Robert
Robert

Reputation: 47

Reverting Multiple commits in git

I've tried the suggestions in posts under this heading to no avail. I also am trying to multiple commits back to a particular point in my project. My latest attempt was: git revert --no-commit f8fae3b..HEAD I got the following error:

error: your index file is unmerged

fatal:revert failed

Upvotes: 0

Views: 672

Answers (2)

Mark Adelsberger
Mark Adelsberger

Reputation: 45819

You have uncommitted changes.

If you don't want those changes, you can throw them out.

git reset HEAD -- .
git checkout -- .

If the changes included new files, they might remain as "untracked"; if that seems like a problem you could git clean

If you do want the changes, you can either commit them (but then you have to make sure you don't accidentally discard them with your revert command) or stash them (git stash). (When you stash them, they'll seem to disappear; but then after you complete the revert you can git stash pop.)

Upvotes: 0

user1785721
user1785721

Reputation:

You have to commit first what you have in your index (staging), or just discard it. git status will help you.

Upvotes: 1

Related Questions