-3

I had committed the changes in git. But, didn't push it. How can i revert my changes from commit.

And is there any chance to stash the single file in git

Can any one please help me

  • Did you try to read some tutorial to git? These are two major topics on most of them. :/ – frlan Jun 19 '14 at 05:52
  • 1
    possible duplicate of [Undo the last Git commit?](http://stackoverflow.com/questions/927358/undo-the-last-git-commit) – Jason Aller Jun 19 '14 at 05:54

1 Answers1

1

You have basically two options:

  • Add a commit to revert this one
  • Actually delete this one (which is possible since you didn't push it yet)

To add a new commit to undo, you just need ton run git revert <sha1>, where <sha1> is the commit you don't want.

To actually delete this commit you could run

git rebase -i <sha1>^

it will open your text editor with a list of commits. Juste delete the line with the commit you don't want, save, and exit. Git will then rewrite your history, removing this commit.

gturri
  • 13,807
  • 9
  • 40
  • 57