【发布时间】:2017-09-30 13:24:21
【问题描述】:
在我的仓库中前后移动以跟踪错误后,例如:
$ git reset --hard fcf9818
发现了错误然后我想继续进行最新的提交,例如:
$ git checkout 32764bf
然后,我开始进行更改并想提交它:
$ git status
HEAD detached at 32764bf
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
我以为我已经是最新的提交了?
但我继续提交:
$ git add -A
$ git commit
[detached HEAD ccf8009] Fixed gird bug on Safari - removing bootstrap grid css. Added code to centralise the image.
2 files changed, 6 insertions(+), 1 deletion(-)
现在我有这个错误:
$ 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>
如果我想在后退后转发到最新的提交,我应该怎么做?
我现在该如何解决这个错误?
编辑:
$ git checkout 32764bf
Warning: you are leaving 1 commit behind, not connected to
any of your branches:
6015d59 Fixed gird bug on Safari - removing bootstrap grid css. Added code to centralise the image.
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> 6015d59
HEAD is now at 32764bf... Added template for finally - only image.
我仍然收到HEAD detached at 32764b:
$ git status
HEAD detached at 32764bf
nothing to commit, working tree clean
【问题讨论】:
标签: git github git-checkout git-reset git-revert