“当前不在任何分支机构”进行提交后
我检查了之前的提交:
git checkout 12345
然后返回到最后一次提交:
git checkout 56789
然后继续提交,我是:
目前不在任何分支上。
也许,我应该这样做:
git checkout master
在第一次结帐后,而不是指向提交 ID。
不过,您知道如何将我的最新提交放入主分支(后面有一些提交)吗?
谢谢
I did a checkout to an earlier commit:
git checkout 12345
Then back to the last commit:
git checkout 56789
And then continued committing and I'm:
Not currently on any branch.
Perhaps, I should've done:
git checkout master
After the first checkout, instead of pointing to a commit id.
Still, any idea how to get my latest commits into the master branch (which is a few commits behind)?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您执行 git checkout 12345 时,您将处于无分支状态。不要那样做。这是为了提交检查而不是在其中工作。
如果您在 master 上并且想要将 master 重置为您想要的提交,请使用 git reset 12345 (或提供
--hard
)如果您想分支,请使用git checkout -b <名称>;
在此时创建一个分支并开始在那里工作。同样,在回来时,就像你提到的,你应该已经完成了 git checkout master
现在你已经提交了超过 56789 的内容,记下超过 56789 的提交,然后 checkout master ,然后执行以下操作:
When you do
git checkout 12345
you will be in no branch state. Do not do that. This is meant for commit inspection rather than working in it.If you are on master and want to reset your master to the commit that you wanted, use
git reset 12345
( or supply--hard
) If you wanted to branch, usegit checkout -b <name> <sha1>
to create a branch at that point and start working there.Similarly while coming back, like you mentioned, you should have done
git checkout master
Now that you have committed over 56789, note down the commit over 56789, and then checkout master, and do:
如果我理解正确的话,您的主分支位于您最近的提交(56789)之后,您希望指出这一点。
如果是这种情况,执行:
将重置 master 分支以指向该提交。之后
git checkout master
就可以开始了。If I understand you correctly, your master branch is behind your most recent commit (56789), and you'd like to make it point to that.
If that's the case, doing:
will reset the master branch to point to that commit.
git checkout master
after that, and you should be good to go.