0

I haven't done this a ton, but I thought that if you add HEAD~somenumber that it will rebase and just show your last x commits. I ran:

▶ gcmsg "added login handling logic"
[user-log-in d66ed88] added login handling logic
 1 file changed, 2 insertions(+), 2 deletions(-)

Up till now I've always simply done git rebase -i develop

I thought to try something I saw in a video about squashing, and I am pretty sure they used HEAD~x to say that they want to only see the last x commits, x being whatever number they specify. Instead what I got as a result of this is a detached head and was like wtf!

So the command I did after that commit above this time was:

git rebase -i develop HEAD~3 

thinking that because of this, that during rebase, it'd show me my last 3 commits. When I saw that it showed a lot more and actually I didn't see my last 3 commits I freaked and did a :q to quit. When I quit it did a rebase:

▶ git rebase -i develop HEAD~3      
Successfully rebased and updated detached HEAD.

When I do a git status, I don't recall if I've seen this before but now it says detached, is this concerning?

▶ git status
HEAD detached from c452a38
nothing to commit, working tree clean

I'm confused here. Now I noticed all my changes are gone. How do I get the head back to this:

▶ gcmsg "added login handling logic"
[user-log-in d66ed88] added login handling logic
 1 file changed, 2 insertions(+), 2 deletions(-)

enter image description here

How can I get myself back to the state I was at, that commit I did? That's all I want to figure out here, this is nuts.

PositiveGuy
  • 17,621
  • 26
  • 79
  • 138

1 Answers1

0

git checkout [branch name you were in when you did the commit]

simple as that. I'm all good now.

PositiveGuy
  • 17,621
  • 26
  • 79
  • 138