在git中标记特定文件 [英] Tag specific files in git

查看:85
本文介绍了在git中标记特定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的git,我想标记分支中的特定文件.例子:我有 master 中的 file1 file2 file3 file4 ,并将这4个文件标记为我的初始版本为 V1.0

I am new git, I want to tag specific files from branch. Example: I have file1, file2, file3, file4 in master and tagged these 4 files as V1.0 for my initial release

现在,我在下一发行版中添加了 file5 ,并合并到了 master 中.
我只需要在新标签中将 file5 标记为 V2.0 ,而不是所有以前的文件( file1 file2 file3 file4 ).
可以在git中完成吗?

Now I have added file5 in next release and merged into master.
I have to tag only file5 in new tag as V2.0 not all the previous files (file1, file2, file3, file4).
Can this can be done in git?

有人可以帮我在git或任何其他可以更新项目的每个版本的解决方案中做到这一点吗?

Can anyone help me how to do this in git or any other solution where I can update my every release of my project?

推荐答案

这可以在git中完成吗?

Can this can be done in git?

不,考虑到标记表示(通常参见下文)提交(这是对所有回购内容的引用,而不是对文件或增量的引用)

No, considering a tag represent (generally, see below) a commit (which is a reference to the all repo content, not to a file or a delta)


图片来自 Git管道

尽管您可以列出在两个标签之间更改的文件:

git diff --name-only v1.0 v2.0

要仅列出 new 个文件,请添加-diff-filter = A :

To list only new files, add --diff-filter=A:

git diff --name-only --diff-filter=A v1.0 v2.0

那将返回' f5 '.

如"如何在GIT中标记单个文件"所述,您可以从技术上标记单个文件或一棵树:

As mentioned in "How to Tag a single file in GIT", you can technically tag a single file or a single tree:

> git ls-tree HEAD
040000 tree 2c186ad49fa24695512df5e41cb5e6f2d33c119b    bar
100644 blob 409940768f2a684935a7d15a29f96e82c487f439    foo.txt

> git tag my-bar-tree 2c186ad49fa24695512df5e41cb5e6f2d33c119b
> git tag my-foo-file 409940768f2a684935a7d15a29f96e82c487f439

但是任何非提交标签都不会用作常规提交标签(例如,您可以签出它).
这些未提交的标记的可能用法:"为什么git标记一个blob或一棵树(或标记)?";.

But any non-commit tag is won't be used as a regular commit tag (you canot checkout it for instance).
Possible usage for those non-commit tags: "Why git tag a blob or a tree (or a tag)?".

这篇关于在git中标记特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆