Reputation: 24998
I have a project that I've been working on with no initial commit. Recently I did git init
.
Now I realized that this needs to be in a branch of its own, let's call it feature-i-should-have-init-first-coded-later
.
How can I move this untracked, uncommited work to the branch while leaving the master empty?
Update:
git status
yields this
On branch master
Initial commit
Untracked files:
(use "git add <file>..." to include in what will be committed)
noob.txt
Upvotes: 2
Views: 145
Reputation: 92854
If you don’t want to commit what you’ve been working on yet - you can stash the changes.
Go through the following steps:
git stash
git checkout -b feature-i-should-have-init-first-coded-later
git stash apply
Now your new branch contains all recent changes
https://git-scm.com/book/no-nb/v1/Git-Tools-Stashing
Upvotes: 1
Reputation: 12418
You can just git checkout -b new-branch
here, since nothing is committed to master yet. You can then stage and commit to the new branch.
Upvotes: 2