Git: "Not currently on any branch." Is there an easy way to get back on a branch, while keeping the changes?
If you have not committed:
git stash
git checkout some-branch
git stash pop
If you have committed and have not changed anything since:
git log --oneline -n1 # this will give you the SHA
git checkout some-branch
git merge ${commit-sha}
If you have committed and then done extra work:
git stash
git log --oneline -n1 # this will give you the SHA
git checkout some-branch
git merge ${commit-sha}
git stash pop
this helped me
git checkout -b newbranch
git checkout master
git merge newbranch
git branch -d newbranch
git checkout master
That's result something like this:
Warning: you are leaving 2 commits behind, not connected to
any of your branches:
1e7822f readme
0116b5b returned to clean django
If you want to keep them by creating a new branch, this may be a good time to do so with:
git branch new_branch_name 1e7822f25e376d6a1182bb86a0adf3a774920e1e
So, let's do it:
git merge 1e7822f25e376d6a1182bb86a0adf3a774920e1e