- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我刚刚发现了 --dirty
git describe
的选项看起来它应该做一些非常有用的事情,即在 git describe
的输出中附加一个后缀当工作树变脏时,但在我的某些存储库中情况似乎并非如此:
$ git status
# On branch 8.30
nothing to commit (working directory clean)
$ git describe --dirty
8.30rel-8-g9c1cbdb-dirty
我认为这可能是因为工作目录相对于标记是脏的,但似乎也不是这样:
$ git status
# On branch 1.4
nothing to commit (working directory clean)
$ git describe --tags --dirty --long
1.4rel-0-gfedfe66-dirty
我曾经广泛使用 hg id
当我以前use Mercurial并且喜欢它的默认行为是添加 +
的事实它为脏存储库报告的任何提交哈希的后缀,因此一直在寻找 git
等效于,但是 git describe --dirty
鉴于文档,似乎没有做我期望的事情:
--dirty[=<mark>]
Describe the working tree. It means describe HEAD and appends
<mark> (-dirty by default) if the working tree is dirty.
我是不是误会了什么--dirty
应该这样做,还是我没有正确使用它?
如果有任何不同,所有的 git 存储库都是通过 buckminster 部署的所以不涉及子模块,文件系统是nfs
分享。
更新:我发现了一个变通办法,但我完全不知道这可能会带来什么不同。
如果我运行 git diff --quiet HEAD
在 repo 协议(protocol)上然后突然git describe
按我的预期工作:
$ git status
# On branch 8.30
nothing to commit (working directory clean)
$ git describe --dirty
8.30rel-8-g9c1cbdb-dirty
$ git diff --quiet HEAD
$ git describe --dirty
8.30rel-8-g9c1cbdb
我还发现当git describe
将存储库报告为 dirty
然后gitk
还显示“本地未提交的更改,未 checkin 索引”,然后列出工作目录中的每个文件,但没有针对它们的差异,只有 ---- filename ----
行。
进一步更新:由于这一直是个问题,我最终写了一个 git-describe-dirty
脚本,首先运行 git describe --dirty
但如果它发现存储库变脏,则运行 git update-index -q --refresh
在再次尝试并取得第二个结果之前。
在遍历数百个存储库时,使用 git describe-dirty
与运行 git update-index -q --refresh ; git describe --dirty
相比,仅运行最初表明它是脏的存储库的索引更新可以节省大量时间。每次。
最佳答案
如果你运行的是 git 1.7.6 或更早版本,你需要在使用 git describe --dirty
之前运行 git update-index --refresh
,因为索引可能是陈旧的。您使用 git diff --quiet HEAD
的解决方法是可行的,因为“git diff”是一个瓷器命令,并且可能会更新索引本身。
git commit that fixes this对于 git 1.7.7 描述了问题:
When running git describe --dirty the index should be refreshed. Previously the cached index would cause describe to think that the index was dirty when, in reality, it was just stale.
请注意,您描述的确切步骤顺序不应该有此问题,因为 git status
更新了索引。但我仍然认为您遇到了同样的问题,因为您描述的解决方法匹配。以下是我如何演示该问题:
% git describe --tags --dirty
v1.0.0
% touch pom.xml
% git describe --tags --dirty
v1.0.0-dirty
% git status
# On branch dev
nothing to commit (working directory clean)
% git describe --tags --dirty
v1.0.0
此处运行“git status”作为副作用更新索引并修复“git describe”输出,就像您的解决方法一样。 git 1.7.6 及更早版本的正确管道修复是:
% touch pom.xml
% git describe --tags --dirty
v1.0.0-dirty
% git update-index --refresh
% git describe --tags --dirty
v1.0.0
关于git - 为什么 `git describe -dirty` 在描述干净 checkout 时添加 `-dirty` 后缀?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16035240/
当我这样做时 git checkout origin/bugfix/NTP-183-datefns git 显示 Note: checking out 'origin/bugfix/NTP-183-d
我刚收到一封来自 Google 的电子邮件,通知我他们将关闭 Google Checkout,我应该改用 Google 电子钱包。这让我感到困惑,因为我在 6 个月前开始使用 Google 数字商品购
SVN 仓库看起来像这样: 最佳/ 最佳 顶部/两个 前/三 ...等等 您不想结帐整个 顶部 文件夹,但您不知道 SVN's sparse checkout feature . 所以你 checko
在稀疏 checkout 场景中,命令 git checkout . 恢复应该忽略的目录。这是设计使然,还是 Git 中的潜在问题?我正在使用 git checkout . 放弃我对我的工作副本所做的
新手问题,我想确保我理解这一点。 当我 git checkout ,这会将整个项目返回到当时的状态,还是仅重新创建在该特定修订版中更改的文件? 例如:如果我的文件夹除了 .git 存储库之外完全是空
我正在使用 Stripe 支付与我的系统集成。但是我不明白这两个库之间的区别。 似乎使用 javascript 生成表单并将 token 传递到我们的服务器端。 这是与 .net 核心一起使用
我正在使用 GitHub Actions 和安装在 Windows 2019 服务器上的自托管代理设置 CI/CD 管道。 我面临的问题是操作 actions/checkout@v2 无法 check
有时是 git checkout命令给出进度反馈: $ git checkout develop Checking out files: 100% (10779/10779), done. Switc
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be
我有一个我喜欢的 checkout 后 Hook - 大多数时候 - 但有时我知道运行它会浪费时间,或者,因为它会删除并重建我的开发数据库,所以我不'希望它做它的事情。 是否有跳过钩子(Hook)
这个问题在这里已经有了答案: Why do we use double dash in "git checkout -- ."? [duplicate] (1 个回答) 关闭 5 年前。 我总是使用
我尝试 checkin 有关我的开发的 excel 文档。但是我的构建失败了,因为它的文件被我锁定了。但问题是;当我选择解锁文档时,出现以下错误。 > The item $/../../Device
通过 XML API,如何将 Google Checkout 回调序列号与原始订单相关联? 在同一行 - XML API doc 的“选项 B - 提交服务器到服务器结帐 API 请求”部分中的序列号
我想确保没有其他人正在检查源代码,以便我可以制作发布的安装程序。所以,我想看看 1) #1正在 check out 特定文件的用户列表和 2) #2所有 checkout 文件的列表;但我不知道该怎么
我正在使用 Google Checkout 制作购物车。我已经像下面这样集成了 Paypal: " /
tl;dr JGit 的 checkout 抛出异常,而命令行 git checkout 工作正常 我目前正在尝试使用 JGit 从在线 Git 存储库中检查某些修订版,使用 Java(用于工作)。我
在使用“git checkout”时,我对这两个选项感到有点困惑 我总是使用 git checkout -- . 来清除我的工作目录。 但今天当我错误地输入 git checkout - . 时。我没
最近我使用了 Google Checkout a.k.a Google Wallet。我的任务是让它作为付款方式步骤中的选项单页结账。 我的 Mangento 版本是 CE 1.6.2.0 默认情况下
最近我使用了 Google Checkout a.k.a Google Wallet。我的任务是让它作为付款方式步骤中的选项单页结账。 我的 Mangento 版本是 CE 1.6.2.0 默认情况下
git checkout - check out 先前 check out 的提交引用。这些信息存储在哪里,是否有类似的方法来访问任何第 n 个以前 checkout 的提交? 我希望能够查看我已 c
我是一名优秀的程序员,十分优秀!