Git 中的文件级跟踪(同一目录中多个分支的文件)
是否有任何脚本可以让人们记住某个目录中文件的单独分支/提交,以便可以同时在同一目录中的分支 1 上的文件 1 和分支 2 上的文件 2 上工作,并让它们正确提交。如果没有我会自己实现。
我的计划是为各种分支/存储库设置隐藏的签出目录,并使用这些文件的链接填充明显的签出目录,以便提交只需提交各自的隐藏分支,但建议将不胜感激。因此,人们可以做类似的事情,
mgit checkout branch1 filename/filegroup
mgit add filename (automatically to it's correct branch/repo)
mgit commit (automatically to it's correct branch/repo)
在任何人告诉我这是一个坏主意或不正确使用版本控制之前,考虑一下应用程序:
在 TeX 中编写学术文档时,您经常会得到一些松散相关的文件,您希望将这些文件保留在版本控制中。问题是这些文件是相关的,并且可以从 git 提供的历史/合并信息中受益,但通常需要独立选择文件的不同版本。最常见的是,您只想处理某篇论文的变体 1,同时也处理另一篇论文的变体 2,但也有 TeX 组合多个文件的情况,因此能够将您选择的变体放在同一文件夹中非常重要。
简而言之,您有一堆具有不同名称的不同文件,这些文件通常彼此派生(论文成为论文),受益于单个存储库,但有十几个不同的签出来处理当前每个文件的任何版本是很麻烦的需要注意。
Is there any script that lets one remember branch/commit seperatly for files in some directory so that one can simultaneously work on file1 on branch1 and file2 on branch2 in the same directory and have them commit appropriately. If not I'll implement it myself.
My plan is to have hidden checkout directories for various branches/repos and populating the apparent checkout with links to these files so that commits simply committed their respective hidden branches but advice would be appreciated. Thus one could do something like
mgit checkout branch1 filename/filegroup
mgit add filename (automatically to it's correct branch/repo)
mgit commit (automatically to it's correct branch/repo)
Before anyone tells me this is a bad idea or incorrect use of version control consider the application:
So often when writing academic documents in TeX you end up with loosely related files that you wish to keep in version control. The problem is that these files are related and can benefit from the history/merging info git provides but often different versions of the files need to be selected independently. Most commonly you simply want to work on variant1 of some paper while also working of variant2 of another but you also have situations where TeX combines several files so it's important to be able to put your choice of variants in the same folder.
In short you have a bunch of distinct files with distinct names which often derive from each other (thesis becomes paper), benefit from being in a single repo but it is unwieldy to have a dozen different checkouts to work on whatever versions of each file currently need attention.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,我认为 git 本身并不支持这一点。
可能是一个本地挂钩,例如 预提交一个 挂钩可能会尝试检查并签出允许提交继续之前的正确分支。
No, I don't think this is natively supported by git.
May be a local hook like a pre-commit one hook might try to check and checkout the right branch before allowing the commit to proceed.