I am facing git issue following below...
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push master HEAD:<name-of-remote-branch>
What shall I do?
I am facing git issue following below...
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use
git push master HEAD:<name-of-remote-branch>
What shall I do?
If you are sure that you on the correct commit locally, then you can just do:
git push origin HEAD:master --force
And then, importantly, change your pointer from the detached head to the current head by:
git branch --force master HEAD
git checkout master
This assumes that you have done the following steps if you wanted to revert to a previous commit which is named "target commit" in the following (as "previous commit" is ambiguous, it could be any previous commit):
git reset --hard <target commit>
You have checked out the code of that commit by:
git checkout <target commit>
If that gives you:
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
<unknown commit> revert to <target commit>
THEN do the git reset
command above again!
IF git status
says:
HEAD detached at <target commit>
nothing to commit, working tree clean
THEN you are ready to push with the command above:
git push origin HEAD:master --force