Tag Archives: [Git]fatal: You are not currently on a branch.

[Git]fatal: You are not currently on a branch.

After chopping hands, the fraud call came before the express delivery was received. How to improve the privacy and security of e-commerce>>>

question:

Error after executing git push command:

bogon:PPAutoPackageScript usrname$ git commit -m "add test.sh"
[detached HEAD da19d347] add test.sh
 1 file changed, 4 insertions(+)
 create mode 100755 xxxxWorkspace/xxxxAPP/PPAutoPackageScript/test.sh
bogon:PPAutoPackageScript usrname$ 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>

This error is literally not on a branch

Check it with the command git branch. It’s not true

bogon:PPAutoPackageScript usrname$ git branch
* (HEAD detached from bdcfe3d8)

solutions:

Through git checkout & lt; branchName> Switch to an existing branch

Note: before performing this step, if you have modified the file, remember to back up your modified content first. Otherwise, after switching branches, the effect is equivalent to a new git code, and your modification will be covered

bogon:PPAutoPackageScript usrname$ git checkout develop
Warning: you are leaving 1 commit behind, not connected to
any of your branches:

  da19d347 add test.sh

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> da19d347

Branch 'develop' set up to track remote branch 'develop' from 'origin'.
Switched to a new branch 'develop'

Check the branch of the local warehouse again, and you have switched to the development branch

bogon:PPAutoPackageScript usrname$ git branch
* develop

If you modify the file again, you can successfully push