Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Introduction to Git Managing Committed Files Commit SHAs and Undoing Commits

Graham Hornecker
Graham Hornecker
10,849 Points

The revert failed and gave me an error. I used "git stash" as the other discussions answered and it did not work out.

I tried to revert an SHA, but it gave me this error:

error: revert is not possible because you have unmerged files.                                                                                  
hint: Fix them up in the work tree, and then use 'git add/rm <file>'                                                                            
hint: as appropriate to mark resolution and make a commit.                                                                                      
fatal: revert failed

and so I resorted to the discussions below the video to see if someone had the same problem. One person did, but the solution they got was to use "git stash" before "git revert" and so I tried and only got the same error. I get these errors after entering this:

git revert 06272

2 Answers

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

Graham Hornecker To proceed with the revert you'd have to resolve the merge conflicts, which you won't learn how to do until our Git Branches and Merging course. I'd recommend doing as git status says, and run:

git revert --abort

...to undo the revert. Then you should be able to run git stash (or even git reset --hard HEAD, if you're willing to lose your work), and then try reverting again.

Jay McGavren
STAFF
Jay McGavren
Treehouse Teacher

I tried to revert an SHA, but it gave me this error:

error: revert is not possible because you have unmerged files.                
hint: Fix them up in the work tree, and then use 'git add/rm <file>'          
hint: as appropriate to mark resolution and make a commit.                    
fatal: revert failed

and so I resorted to the discussions below the video to see if someone had the same problem. One person did, but the solution they got was to use "git stash" before "git revert" and so I tried and only got the same error. I get

I don't think git stash will work after you have a merge conflict, it would only help before you have one.

git status should always be the first command you run when you have a strange situation like this. It should give the necessary info to get out of this situation. Can you run git status, and copy-paste the output in a comment on this forum thread? Be sure to consult the Markdown Cheatsheet in the comment form so you can format the pasted text as code.

Graham Hornecker
Graham Hornecker
10,849 Points

My results were as followed:

treehouse:~/workspace/medals$ git status                                                                                                        
On branch master                                                                                                                                
You are currently reverting commit d61f690.                                                                                                     
  (fix conflicts and run "git revert --continue")                                                                                               
  (use "git revert --abort" to cancel the revert operation)                                                                                     

Changes to be committed:                                                                                                                        
  (use "git reset HEAD <file>..." to unstage)                                                                                                   

        deleted:    bronze.html                                                                                                                 

Unmerged paths:                                                                                                                                 
  (use "git reset HEAD <file>..." to unstage)                                                                                                   
  (use "git add <file>..." to mark resolution)                                                                                                  

        both modified:   medals.html                                                                                                            

Should I follow the recommendation and just add medals.html to the stage?

(EDIT) Or am I just going to do "git revert --continue"?