在设置OpenEmbedded项目之后,源被设置为分离头状态。如何确定从哪个分支(本地还是远程)签出源代码?
是的,您可以查看分支并比较代码。有没有更简单的方法?
我正在使用Git版本1.7.1。
$ git config -l
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
remote.origin.url=git://arago-project.org/git/projects/meta-arago-amsdk.git
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.amsdk-06.00.00.00-integration.remote=origin
branch.amsdk-06.00.00.00-integration.merge=refs/heads/amsdk-06.00.00.00-integration
$ git branch -a
* (no branch)
amsdk-06.00.00.00-integration
master
remotes/origin/HEAD -> origin/master
remotes/origin/amsdk-05.06.00.00-integration
remotes/origin/amsdk-05.07.00.00-integration
remotes/origin/amsdk-05.08.00.00-integration
remotes/origin/amsdk-06.00.00.00-integration
remotes/origin/master
remotes/origin/master-upstream发布于 2013-09-06 22:40:35
解决方案1: git reflog
如果您的工作副本进入分离头状态后还没有移动您的HEAD引用,则可以使用git reflog -1查找在以下位置分离您的头部:
git reflog -1
d761f4a HEAD@{0}: checkout: moving from feature to head~5请注意,我不确定这些信息是否在较早版本的Git中可用。
即使您一直在移动您的HEAD引用,您也可能仍然能够找到在reflog中某个地方分离的点:
git reflog | grep checkout对于无法访问grep的用户,可以在PowerShell中使用findstr,或者使用Git中内置的这些标志:
git log --walk-reflogs --grep-reflog "checkout" --oneline解决方案2:查找包含当前提交的所有分支
查找包含当前签出的提交的所有分支(本地分支和远程跟踪分支):
git branch --all --contains HEAD然后,只需检查每个分支的第一个提交,看看给定的提交是否是该分支的头:
git log -1 <branch>https://stackoverflow.com/questions/18667578
复制相似问题