git branch
和git status
后,这是我在终端输出的输出
**
denis@N56VJ:~/Workspace/ita-javaee-04$ git status
HEAD detached from refs/heads/master
Untracked files:
(use "git add <file>..." to include in what will be committed)
src/main/webapp/package-lock.json
nothing added to commit but untracked files present (use "git add" to track)
denis@N56VJ:~/Workspace/ita-javaee-04$ git branch
* (HEAD detached from refs/heads/master)
master
denis@N56VJ:~/Workspace/ita-javaee-04$
答案 0 :(得分:0)
您可以删除旧主人并在当前头部创建一个新主人。
git branch -D master
git checkout -b master
git branch --set-upstream-to=origin/master
如果您一直担心犯错,请务必git show HEAD
,git show master
,并将sha1哈希保存为备份。或者,您可以依赖git reflog
。