Letharion
Letharion

Reputation: 4229

How do I ask git, which commits are not on a branch?

I haven't payed enough attention, and been working for a little while on "no branch".

The problem is that my works spans weeks of time, and perhaps 10 commits, so it's now obvious to me what exactly has been commited to the right branch, and what has not.

How do I ask git for all the commits that I've created that don't belong in any branch? And can I merge them all in easily, or do I need to do one merge per commit?

Upvotes: 2

Views: 329

Answers (1)

Bombe
Bombe

Reputation: 83855

If you are still where you made your last commit you can simply create a new branch with

$ git branch new-branch

If you don’t have any modified files in your working directory you can now switch to that branch you just created:

$ git checkout new-branch

Now you can continue as usual, moving commits around using git cherry-pick or git rebase.

Upvotes: 1

Related Questions