0

I'm working with a local repo and there are no upstream repos. I had a single branch 'master' in which HEAD referred to the most recent commit. In an attempt to accomplish something* I did a:

git rebase -i master

which brought up the editor window so I could do my picks and squashes. Uncertain of what to do next, I closed the editor (no changes were made) and was told by git:

Successfully rebased and updated refs/heads/master.

That was the sum total of git's response.

I have two questions here:

First, did anything actually change in my branch and what condition is my branch in now? (I realize that's two questions in 1.)

Second, if there was an impact from this command, how do I undo?

Howiecamp
  • 2,981
  • 6
  • 38
  • 59
  • If you didn't make any changes in the editor, then no changes were made - you just rebased something onto itself, which does nothing. – Aaron Brager Sep 18 '15 at 22:25
  • 1
    You can use `git reflog` to see a list of all changes, so you could check out the code from before the rebase if you want. But it should be unchanged based on your description – Aaron Brager Sep 18 '15 at 22:26
  • @aaron I'm surprised git responded to the command stating that an action had been taken if there were indeed no changes. In other scenarios git tells you "No changes made" or "Nothing to do". Thanks for the tip on reflog. – Howiecamp Sep 19 '15 at 19:49
  • 1
    To the downvoter - If you want your downvotes to improve the site then it would be helpful to comment on why you're downvoting. As it stands I have no idea hence I've learned nothing about how to possibly improve my comment and all you've done is make me feel bad. – Howiecamp Sep 19 '15 at 19:51
  • I just saw same thing happen in git today. I started an interactive rebase, but when the file opened in vi, I changed one file to "s" (squash), but decided I did not want to do this anymore, so tried to stop the process, "!q" but git acted as if I had finished the rebase process and said "Successfully....". I'm just as baffled as OP about how to figure out if any commits were damaged. I did not delete any rows, but I did set one as "s" before trying to back out. – pauljohn32 Apr 13 '20 at 18:40

1 Answers1

0

First, did anything actually change in my branch...

If the editor said "noop", then there wouldn't have been any changes, as there were no SHAs to process.

If the editor did have any SHAs in it, you run the risk of having changed history. The likely thing that would be impacted would be merge commits.

...and what condition is my branch in now?

Use git status to inspect that. If it informs you that your branch and your remote branch have diverged, you've rewritten history. Otherwise, I wouldn't sweat it.

[I]f there was an impact from this command, how do I undo?

Provided that you have not force-pushed this branch, you can reset the state of your local branch to match that of the remote branch.

git fetch
git reset --hard origin/master

If you have force-pushed, then you should ask that someone who pulled a copy of the repository (and hasn't dealt with the rebasing of master yet) to force-push their master branch.

Makoto
  • 104,088
  • 27
  • 192
  • 230
  • I don't know what the editor had in it unfortunately. I had assumed (incorrectly?) that if I exited without making any changes that it would be a noop? – Howiecamp Sep 19 '15 at 19:52
  • It depends on what you're rebasing against. If you have merge commits, you won't have a noop state. – Makoto Sep 19 '15 at 21:42
  • I meant to also say earlier that this is the only repo - there's no remote repo. – Howiecamp Sep 20 '15 at 01:16