git 标签和时间
我的印象是,标签的作用就像提交,因为如果我有一个基于旧提交的克隆,我不会期望看到 git 标签输出中列出的新标签。
然而,这种假设显然是错误的。它破坏了我计划使用标签的方式。我正在使用简单的标签。随着时间的推移,其他类型的标签的工作方式是否会有所不同?
I was under the impression that a tag would act like a commit in that if I have a clone based on an old commit, I wouldn't expect to see new tags listed in the git tag output.
However, this assumption is evidently wrong. It kinds wrecks the way I was planning to use tags. I am using simple tags. Would some other type of tag work differently as far as time goes?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不确定你的目标,但是 git 并不能轻松地按指向的提交日期对标签进行排序。
经过一些研究和努力,我想出了这个:
示例输出:
经过一些调整,这也可以与“git分支”一起使用来处理指示当前分支的星号。
另一个可能有用的命令......
在日志输出中包含引用名称(分支、标签等):
您是否有依赖于旧克隆中不存在新标签的假设的工作流程或脚本?
如果您要克隆本地存储库,您可以尝试“git clone --no-hardlinks”。但这可能不是实现您目标的最佳解决方案。
I'm not sure of your goal, but git doesn't make it easy to sort the tags by the date of the commits pointed to.
After some research and effort I came up with this:
Sample output:
With a little tweaking, this can also works with "git branch" to handle the asterisk indicating the current branch.
Another command that may be helpful...
Include the ref names (branch, tags, etc) in the log output:
Do you have a workflow or script that relies on the assumption that newer tags don't exist in old clones?
If you're cloning a local repo, you could try "git clone --no-hardlinks". But it may not be the best solution for your goals.
正常情况下的
git tag
是固定的。如果您昨天引用它并今天引用它,它将指向相同的 SHA/tree/checkout。但是,随着时间的推移以及您更改存储库(本地或由于
git-fetch
等),相同的 SHA 可能有更多方法来描述 (git describe
)相同的提交。多个标签可能指向相同的 SHA(如果没有提交直接指向 SHA,则指向附近的提交),并且gitdescribe
返回的一个可能会发生变化。也许你可以描述你正在尝试做的事情,人们可以看看是否有任何想法。
A
git tag
under normal circumstances is fixed. If you reference it yesterday and reference it today, it will point to the same SHA/tree/checkout.However, as time progresses and you change your repository (either locally or due to
git-fetch
et al) the same SHA may have more ways to describe (git describe
) that same commit. Multiple tags may point to the same SHA (or nearby commits if no commit points directly to the SHA) and which onegit describe
returns may change.Perhaps you can describe what you are trying to do and people can see if there is are any ideas.