2

Allright, somehow, I dropped off of my main branch.

Here's what I've done: git reflog:

00b0dbf HEAD@{5}: commit: Beginning to update and create functions from static analysis files
654d826 HEAD@{6}: checkout: moving from master to remotes/origin/master
654d826 HEAD@{7}: commit: Deleting old files
fac781a HEAD@{8}: commit: updating gitignore, removing old files
b8b4ef6 HEAD@{9}: commit: updating gitignore
c1c24f7 HEAD@{10}: commit: removing old files
8d1d5cb HEAD@{11}: commit: Changed base.r to represent new file structure
7d3f2d0 HEAD@{12}: commit (initial): First commit

"Somehow" I moved off the master.

So now, when I try to commit changes I get: "Not currently on branch".

What I'd like to do is reload from commit 654d826 HEAD@{7} as that was really the last time I changed anything vital.

How do I get back to "master" and rebase from commit 654d826 HEAD@{7}

1 Answer 1

3

You simply checked out a remote tracking branch. These do not track your commits, hence you will be in detached head state as it says. You want to update the master branch with that last commit you did:

git push . HEAD:master

then get back to master so subsequent commits will be tracked:

git checkout master

should the first push not work, that means you did other commits on master. In this case, make a temp branch where you are:

git branch temp

then go to your master branch

git checkout master

then merge what you did when you were in the detached state:

git merge temp

You should now be able to continue to commit and track your work in master.

Not the answer you're looking for? Browse other questions tagged or ask your own question.