如何在同一个存储库中保持两个文件同步? [英] How can I keep two files in sync within the same repository?

查看:132
本文介绍了如何在同一个存储库中保持两个文件同步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

   - 项目回购
- 子文件夹1
- 文件1
- 文件A
- 文件夹2
- 子文件夹
- 文件2
- 文件B

文件1和文件2是精确的副本,而不是手动同步它们,我想用git自动执行。同时文件A和B不一样,我不希望它们被同步。是否有可能在git中同步文件?

解决方案

希望符号链接是您所需要的。



如果您使用的是Linux / Unix版本,您可以按如下方式发出符号链接创建命令:

  cd... / Project Repo / Sub Folder 2 /
ln -s../Sub Folder 1 / File 1File 2

在支持符号链接的Windows版本中,您可以尝试mklink命令:

  cd ... \Project Repo \ Sub文件夹2 
mklink文件2.. \子文件夹1 \文件1


My repository in git looks like this:

-Project Repo
    -Sub Folder 1
         -File 1
         -File A
    -Sub Folder 2
         -SubSub Folder
              -File 2
              -File B

File 1 and File 2 are exact copies and rather than manually sync them, I'd like to do that automatically with git. At the same time Files A and B are not the same and I do not want them to be sync'd across. Is it possible to keep to files in sync in git?

解决方案

Hopefully a symbolic link is all you need.

If you are in Linux/Unix you would issue the symlink creation command as follows:

cd ".../Project Repo/Sub Folder 2/"
ln -s "../Sub Folder 1/File 1" "File 2"

In a version of Windows that support symbolic links, you can try the mklink command:

cd ...\Project Repo\Sub Folder 2
mklink "File 2" "..\Sub Folder 1\File 1"

这篇关于如何在同一个存储库中保持两个文件同步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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