File Level Tracking In Git (Files from multiple branches in same directory)

情到浓时终转凉″ 提交于 2019-12-07 10:43:40

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/7784825/file-level-tracking-in-git-files-from-multiple-branches-in-same-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!