1

I am using netbeans to pull/commit/push to git. I have accidentally make commit before pull request and now it's asking me Rebase/Merge. Either of option gives me error. I tried with following links using Windows git shell

How to undo last commit(s) in Git?

How to revert Git repository to a previous commit?

How to undo last commit

Remove a git commit which has not pushed

I have tried following commands:

git checkout <commit sha key>
git reset --hard <commit sha key>

NOTE: I have commited change but not pushed!

Community
  • 1
  • 1
Disha V.
  • 1,834
  • 1
  • 13
  • 21
  • I often give up and just clone the repo again in a fresh directory. Git seems to have a dozen indirect ways to do this that only sometimes work, and no simple clear reliable way to do this. Otherwise you need to give the complete text of the commands you tried and the error messages for someone to solve your particular problem. – WillShackleford Oct 16 '15 at 11:36
  • @WillShackleford edited! – Disha V. Oct 16 '15 at 12:44
  • latest edit still doesn't show what the error was – WillShackleford Oct 16 '15 at 12:55
  • It gives me `REBASE` in shell and i don't know how to proceed? – Disha V. Oct 17 '15 at 04:25
  • I do not know what it gives me `REBASE` means. I assume there is some error message that includes the word REBASE. In which case we need the complete error message and the complete set of commands that produced it. – WillShackleford Oct 17 '15 at 08:08

1 Answers1

2

try git reset --soft HEAD~1

when you haven't pushed yet, a soft reset will take all the changes from the latest commit, and place them back onto stage again. in other words, the status of your repo will look exactly as it was the moment before you commited.

AdamJSim
  • 113
  • 1
  • 8