我对 GIT 生活的恐惧:我没有分支!

发布于 2024-08-20 01:27:53 字数 179 浏览 5 评论 0原文

我已经检查了一个旧的哈希(提交)并正在处理它,愉快地检查并忽略我不在分支工作的警告。然后我切换到一个分支,并意识到我无法返回到我的孤立签入(幸运的是,我的终端窗口仍然打开,所以我检查了它并分支)。

我怎样才能让 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

离去的眼神 2024-08-27 01:27:53

git reflog 将显示您最近完成的活动创建的引用的日志。为了将来参考,提交的 git checkout 会让您处于分离状态头。如果您想将工作建立在旧提交的基础上,则应该从该提交创建一个分支。

git checkout -b newbranch oldsha1

或者

git branch newbranch oldsha1
git checkout newbranch

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.

git checkout -b newbranch oldsha1

or

git branch newbranch oldsha1
git checkout newbranch
情深如许 2024-08-27 01:27:53

请参阅这个问题,它很好地解释了如何找到你掉落的藏品。您可以以相同的方式查看悬空提交等。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文