Harry Forbess
Harry Forbess

Reputation: 2134

I have added and commited on non existant branch; how do I get that commit onto a branch?

I added some untracked files and committed them, then I tried to push them and it said I wasn't on a branch. So I looked and I had branches

   * current
   Master

So I switched to branch master. The files are still there, but I don't remember all of their names. I can't switch back to the * branch.

How can I find that commit so I can push those untracked files? I have seen this happen before; I don't know how I keep doing it.

Upvotes: 0

Views: 33

Answers (1)

Simon Boudrias
Simon Boudrias

Reputation: 44619

Check git reflog it'll list all the commits your HEAD was on.

The lone commit will probably be there. To merge it onto master, you could just git cherry-pick <commit SHA>

Upvotes: 1

Related Questions