Reputation: 9140
I have been working in git submodule and I was ready to push my changes when I got this message:
$ git push
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push origin HEAD:<name-of-remote-branch>
I ran the following command thinking this may fixed:
git checkout master
But I got this message:
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
2f1b645 my changes
If you want to keep it by creating a new branch, this may be a good time
to do so with:
git branch <new-branch-name> 2f1b645
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
My question to you guys is how can push my changes to master?
Upvotes: 1
Views: 1008
Reputation: 2417
Just cherry-pick that commit on your master branch:
git cherry-pick 2f1b645
The problem you had was that you were not on a local branch when you committed that changes.
By the way, you could also have rebased or merged your commit.
git rebase 2f1b645
or
git merge 2f1b645
Probably to rebase it would have been the nicest solution, but since I'm not 100 percent sure what you had checked out, the cherry pick is the safest way to go.
Upvotes: 3