HEAD detached at origin/master

前端 未结 2 1592
后悔当初
后悔当初 2021-01-30 18:11

I\'ve just checked out an old project to fix a bug. git reports:

HEAD detached at origin/master

git status reports I have an untra

2条回答
  •  抹茶落季
    2021-01-30 18:24

    No you're not on the master branch, your on some kind of "newly invented" branch without a name that was once the master.

    You simply need to switch back to the master:

    git checkout master
    

    However if you wish to fix a bug, you should work at your own branch (according to most git workflows). Thus checkout the master and branch from it:

    git checkout master
    git checkout -b fix-issue #give the branch a name that refers to the bug
    

    then fix the bug and run:

    git checkout master
    git merge --no-ff fix-issue -m "Fixed some strange issue, here follows a description"
    

    EDIT

    As specified in your question you have an untracked file. If these file(s) are of no importance, you can remove them. If on the other hand you wish to maintain them, you can merge them into the master first.

    Therefore you create a temporary branch:

    git commit -m "some temporary message"
    git checkout -b temporary
    git checkout master
    git merge --no-ff temporary
    

提交回复
热议问题