Rebase将HEAD分离为主人

时间:2017-11-14 13:31:23

标签: git

你能帮我解决这个问题吗?我在一个分支**(HEAD与refs / heads / master分离),我有一些新的提交,我需要将这些更改添加到我的主分支。你告诉我该怎么做?输入git branchgit 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$ 

1 个答案:

答案 0 :(得分:0)

您可以删除旧主人并在当前头部创建一个新主人。

git branch -D master
git checkout -b master
git branch --set-upstream-to=origin/master

如果您一直担心犯错,请务必git show HEADgit show master,并将sha1哈希保存为备份。或者,您可以依赖git reflog