我对 GIT 生活的恐惧:我没有分支!
我已经检查了一个旧的哈希(提交)并正在处理它,愉快地检查并忽略我不在分支工作的警告。然后我切换到一个分支,并意识到我无法返回到我的孤立签入(幸运的是,我的终端窗口仍然打开,所以我检查了它并分支)。
我怎样才能让 GIT 告诉我不属于分支的提交的名称?或者只是所有提交,如果不可能的话......
I had checked out an old hash (commit) and was working on it, checking in merrily and ignoring warnings that I wasn't working in a branch. Then I switched to a branch and realized that I had no way to get back to my orphaned checkins (luckily I had the terminal window open still, so I checked it out and branched).
How can I get GIT to tell me the names of the commits that do NOT belong to a branch? Or just all the commits, if that's not possible...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
git reflog
将显示您最近完成的活动创建的引用的日志。为了将来参考,提交的 git checkout 会让您处于分离状态头。如果您想将工作建立在旧提交的基础上,则应该从该提交创建一个分支。或者
git reflog
will show the log of the references created by recent activity you've done. For future reference,git checkout
of a commit puts you on an detached head. If you want to base work on an old commit, you should create a branch off of that commit instead.or
请参阅这个问题,它很好地解释了如何找到你掉落的藏品。您可以以相同的方式查看悬空提交等。
See this question which has a great explanation of how to find stashes you've dropped. You can see dangling commits etc. the same way.
您可以从引用日志中取出它们,该引用日志存储您已签出的提交。
git reflog 将打印出 HEAD 指向的最新提交,这是您的工作副本。
您还可以使用 git fsck 获取树中当前分支无法访问的所有对象的列表。
You can fish them out of the reflog, which stores the commits which you've had checked out.
git reflog
will print out the most recent commits pointed to by HEAD, which is your working copy.You can also get a list of all objects in your tree which are unreachable from your current branches using
git fsck
.