- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
为什么 git status 和 git show 不一致?
存储库应该位于标签中。这是 git status 告诉我的(散列从 609b 开始)。
但是 git show 告诉我它正在提交,哈希值从 156f 开始。
目前的情况是执行以下操作以获取标签处的代码库。
git clean -f && git reset HEAD --hard && git fetch && \
git fetch --tags && git checkout daily-build-492 && git pull
为什么不一致?
一些诊断:
$ git status
HEAD detached from daily-build-492
nothing to commit, working directory clean
$ git rev-list -n 1 daily-build-492
609b538fb0180b170170be09312fecf5a5240b6a
$ git show
commit 156f9e6b3fbfe7c16e8d821efd315428610043c2
Merge: ec154d9 15e8876
Author: ubuntu <ubuntu>
Date: Wed Dec 2 14:09:23 2015 +0000
Merge branch 'deploy-server'
$ git describe --tags --exact-match
fatal: no tag exactly matches '156f9e6b3fbfe7c16e8d821efd315428610043c2'
$ git log --tags --simplify-by-decoration --pretty="format:%ai %d" |grep 492
2015-11-23 07:05:18 +0000 (tag: daily-build-492)
最佳答案
我认为您同时被两个问题搞糊涂了。首先,您处于分离的 HEAD 状态。 Daily-build-492 是一个标签,您不能对标签进行更改。如果你在 master 中 checkout 标签(例如)git 会首先给你这样的消息:
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
这基本上就是您在执行 git checkout daily-build-492
时可能做的事情。如果您现在执行 git status,您将收到一条如下所示的消息:
$ git status
HEAD detached at daily-build-492
之后,您连接(使用 &&)一个 pull 命令,该命令从链接的远程获取更改。我的猜测是,因为这会添加对标签的更改并且因为这是不允许的,所以您会自动从 daily-build-492 分离到更远的边缘 :) 现在通知将是:
$ git status
HEAD detached from daily-build-492
nothing to commit, working directory clean
如您所见,这正是您的 git status 在您执行初始命令后实际告诉您的内容。
Git status 只显示索引文件和当前 HEAD 之间的所有差异。这基本上意味着与 HEAD 相比,您所做的所有更改都是全新的文件、更改或阶段性更改。基本上你是 git status 告诉你没有变化,你已经脱离了 HEAD。
Git 显示
git show 做了一些不同的事情。 Git show 显示对象的信息。 git 中的一个对象可以是很多东西;一个提交,一个标签,一棵树等。如果你不给 git show 一个对象散列行为似乎是 git show 最后一次提交。这是您在 checkout 标签后 pull 入的提交。使您进入分离 HEAD 模式的提交之一。
简单重现您的问题
git init test.git
cd test.git
touch A
git add A
git commit -m "A, jay"
touch B
git add B
git commit -m "B, jay"
git tag TAG-1
git checkout TAG-1 //Now you will get the notice about git detached HEAD etc
git status // result below
//HEAD detached at TAG-1
//nothing to commit, working directory clean
touch C
git add C
git commit -m "C, shoopdawhoop" // a warning like below is outputted,but it works
//[detached HEAD eda8080] C
// 1 file changed, 0 insertions(+), 0 deletions(-)
// create mode 100644 C
git status // output below again
// HEAD detached from TAG-1
// nothing to commit, working directory clean
git show // will now tell us about commit C the last one we added.
// commit eda808088594ae7b05ae1b57ffd95f7f810a9091
// Author: a@example.net <a@example.net>
这一小组命令基本上模仿了我认为您所做的。也许命令的 && 串联使输出静音,也许没有但您没有发布。这个故事的寓意是你试图做一些 git 不允许的事情。
正如您在示例中看到的,这解释了为什么您的 git describe --tags
没有产生任何结果,因为您给它提供了提交 C 的哈希值(不是真的,但它类似于提交C 在我的例子中。)
您的 git rev-list
确实给了您所期望的,因为您特别要求它用于 daily-build-492 中的最后一次提交。
关于git - 为什么 git status 和 git show 不一致?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34045598/
我对文档有点困惑。请纠正我。 git 状态- 显示当前本地工作目录状态 git status -u- 显示未跟踪的文件(也是本地的) git 状态 -uno- 不显示未跟踪的文件(也是本地的)?? 后
我有一个具有 12 个虚拟机资源的 ARM 模板。每个虚拟机都有 1 个与其关联的 CustomLinuxScript 扩展资源。 某些 CustomLinuxScript 扩展失败并出现错误:状态文
我有一个具有 12 个虚拟机资源的 ARM 模板。每个虚拟机都有 1 个与其关联的 CustomLinuxScript 扩展资源。 某些 CustomLinuxScript 扩展失败并出现错误:状态文
我有以下 JavaScript 代码: alert(data.status); data 是一个 JSON 对象,其字段之一是 status ( bool 字段)。 当JSON.stringify(d
我在验证表单时遇到此错误,如何解决它。 代码: app.post('/',[ check('username','Error occured in Username').trim().isEmai
我正在开发一个使用 fork() exec() wait() 的 C 程序。第一个进程有以下代码: int main(int argc, const char * argv[]) { // inser
我想在 git status 上运行 linter,但是似乎没有 pre-status 和 post-status Hook 。 如何给 git 添加一个钩子(Hook)? fine docs对此事保
我需要获取所有 current_user.friends 状态,然后按 created_at 对它们进行排序。 class User a.created_at } end current_user.
我在 Eloquent 中使用 orWhere 时遇到问题。 我有一个团队,这个团队有一些资料。我想获取状态 = 1 或状态 = 2 的所有配置文件。但我无法让它工作。 我的代码是这样的: $prof
http://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic.html#INISCRPTACT 根据这
我们在 IIS 6.0 上托管 WCF 服务的服务器之一上观察到以下行为: IIS 日志显示所用时间的值较高 (> 100000) HTTP 状态码是 200 sc-win32-status 代码显示
在 Dynamics CRM 中,潜在客户实体同时具有状态和状态原因。使用 API 我可以获得所有状态原因。我被绊倒的地方是当我的用户选择状态原因时我想倒退并找出哪个状态与所选状态原因相关联。 以下是
我很好奇返回响应和仅创建响应的区别。 我见过大量使用 return res.status(xxx).json(x) 的代码示例和res.status(xxx).json(x) . 谁能详细解释一下两者
文档并没有真正说明 status 是什么。 status 到底是什么? http://man7.org/linux/man-pages/man2/exit_group.2.html 最佳答案 来自ex
An earlier question导致了一些关于如何检查 Git 存储库是否包含脏索引或未跟踪文件的想法。我从那次讨论中采纳的答案如下: #!/bin/sh exit $(git status -
ECSHOP出现 XMlHttpRequest status:[500] Unknow status 这个错误 把/admin/templates/top.htm 这个文件中{insert_scr
我有以下代码用于通过 Twitter4J 获取推文: List statuses; Paging paging = new Paging(1, LIMIT); statuses = twitter.g
非常不言自明。我正在制作一个脚本并且遇到了被使用和解析的情况,但它们的输出似乎总是完全相同。 最佳答案 git status --branch --porcelain "显示分支的状态(ahead,
我有一张表,上面有如下记录 表A subid clickid status datetime 1 123 low 2018-07-24 20:20:44 2 123
如果确实缺少资源,我的 API 将返回以下内容 { "code": 404, "message": "HTTP 404 Not Found" } 当我使用代码 Response.sta
我是一名优秀的程序员,十分优秀!