3

Here is the problem: I have a project, I connected to my live git repo via netbeans, and I made a commit. Then I tried to pull the code, I got a message that do I want to merge with the master or I want to rebase, I accidentally rebased. Now I didn't had any git repo initialized in my local project (copied code from USB). Rebasing initialized a replica of git repo. what happened with this action is really annoying. All the changes that I made in the current directory are removed files are deleted too, I have recovered the deleted files. But I am still unable to go back to the state before rebase (i.e. fresh state). Any help will be really helpful.

jthill
  • 55,082
  • 5
  • 77
  • 137
temp-learn
  • 527
  • 2
  • 9
  • 31
  • ASCII graphs of the current and desired states of your repo would help you get an answer. – jub0bs Dec 08 '14 at 18:51
  • @Jubobs: how to get them – temp-learn Dec 08 '14 at 18:52
  • See [here](http://stackoverflow.com/questions/25488138/move-initial-commits-off-master-to-another-branch-in-git/25490288#25490288) for an example. – jub0bs Dec 08 '14 at 18:53
  • "All the changes that I made in the current directory are removed files are deleted too" -- git goes to great lengths to never do that, [to the extent that it can confuse or annoy newcomers](https://www.google.com/webhp?q=please+commit+or+stash). Git simply won't stomp on uncommitted work without you outright ordering it to do so. "Now I didn't had any git repo initialized in my local project (copied code from USB). Rebasing initialized a replica of git repo" -- git rebase imply does not do this. Please add a tag for your IDE or whatever, people who understand it might know what it's doing. – jthill Dec 08 '14 at 21:10
  • @jthill:adding a tag can bring me to initial state? – temp-learn Dec 08 '14 at 21:12
  • No, add a tag to this question. – jthill Dec 08 '14 at 21:12
  • Can you please show, by way of diagram, what your local branch looked like before and after the accidental rebase? E.g. master: A <- C, local: A <- B <- C – Tim Biegeleisen Dec 09 '14 at 12:51

2 Answers2

12

If you would like to continue/abort rebasing in Netbeans after resolving any conflicts. From the top menu click:

Team -> Branch/Tag -> Rebase...

Click Continue or Abort

dehart
  • 1,554
  • 15
  • 18
2

git rebase --abort in the command line (don't know in the Netbeans IDE) will revert the changes made during accidental rebase.

It's possible that you can find a backup of your commit using git reflog.

Martín Schonaker
  • 7,273
  • 4
  • 32
  • 55
  • 1
    `git rebase --abort` will only be useful if the rebase operation is still in progress. Whether that's the case here is unclear. – jub0bs Dec 08 '14 at 18:21
  • @Jubobs If the rebase operation has finished, you'll get a regular commit. `--abort` resets to the previous HEAD. Check http://git-scm.com/docs/git-rebase. – Martín Schonaker Dec 08 '14 at 18:25
  • That is just not true. If you run `git rebase --abort` when no rebase operation is in progress, you only get the message `No rebase in progress?`. No commit is created and `HEAD` does not change. – jub0bs Dec 08 '14 at 18:40
  • 1
    @Jubobs:Is Correct here, i actually endorse it after checking – temp-learn Dec 08 '14 at 18:51