Git Reset or Discard or Remove keeps uncommited changes

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

Hey i m having troubles reversing to the latest commit. It keeps saying I have uncomitted changes. I tried:

git reset --hard HEAD, selecting the files and removing them, discarding them, stop tracking them, i even tried rebranching but that also gives the uncommitted changes error, They just keep bumping up in my uncommitted changes. Either as a changed file, or a removed file. How do I just revert back to the latest commit, discarding all uncommitted changes in this branch so that I can pull in a new one. this is really grinding my gears since before I never encountered it that I couldn t just undo my changes..

Answers

If you want to completely drop the most recent commit, then you should do a hard reset to the commit just before the HEAD.

git reset --hard HEAD~1

Except if you have already pushed that commit somewherw where it s visible to others. In that case youd have to git push --force afterwards and everyone else would be in a world of hurt the next time they pull and you ve rewritten history.

In that case it would be better to simply do

git revert HEAD

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/38100637/git-reset-or-discard-or-remove-keeps-uncommited-changes

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils