本文介绍了如何查找未由git跟踪的文件,然后重新同步这些文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的系统是centos7.

我使用git ls-files获取git跟踪的文件.
并使用git lfs ls-files获取git-lfs跟踪的文件.

但是在我的开发目录中,有一些文件夹和文件不应该被版本控制软件跟踪,例如userdataupload/avatar.
假设stackoverflow是我的网站.像你和我这样的用户将上传头像.这些文件经常更改,并且不应该被git跟踪.

当我将这些文件部署到生产服务器时,这些文件是必需的,然后我想到了:
Git具有git clean -f -d之类的良好功能,但是我不想删除仅列出那些文件.
rsync -aH not_tracked_files root@production server:/home/mywebsite.

我不知道如何在rsync脚本中获取not_tracked_files.

解决方案

它们需要存储在另一个引用(不是您的Git存储库)中,并在部署过程中获取(涉及rsync)

它可以是私人Nexus服务器,可以是私人共享文件夹,远程驱动器(onedrive/Google驱动器,AWS ...),甚至是保管库,但它不应是您当前的Git存储库. /p>

面临的挑战是非不能被Git跟踪"文件的版本:如果它们不经常更改,则可以将它们简单地静态存储一次,并在您进行部署时进行检索.
如果它们定期更改,则需要在Git存储库中跟踪对这些文件的正确版本的引用(有点像lfs对于大型文件,它们也存储在其他位置)


这些工件类型很特殊,因为您通常只需要它们的最新版本即可.
可以在独立的引用中对其进行管理.例如,GitHub通过其自己的(历史)服务 gravatar.com 来管理其头像.

这意味着您要部署的内容应该是:

  • 对化身的引用
  • 一个程序,该程序能够在部署后从其参考中获取化身,并在需要时在生产服务器上复制/更新它们.

My system is centos 7.

I use git ls-files to get files tracked by git.
And use git lfs ls-files to get files tracked by git-lfs.

But in my develop directory, has some folders and files should not tracked by version control software,like userdata,upload/avatar.
Suppose stackoverflow is my site.User like you and me will upload avatar.These files often changed and should not tracked by git.

Those files are necessary when I deploy to production server,then I have thought:
Git has good function like git clean -f -d,but I don't want to delete just list those files.
rsync -aH not_tracked_files root@production server:/home/mywebsite.

I don't know how to get not_tracked_files in rsync script.

解决方案

They need to be stored in another referential (other than your Git repository), and fetch during your deployment process (which involves rsync)

It can be a private Nexus server, it can be a private shared folder, a remote drive (onedrive/Google drive, AWS...), or even a vault, but it should not be your current Git repo.

The challenge is the version of not "not tracked by Git" files: if they don't change often, they can simply be statically stored once, and retrieve whenever you do your deployment.
If they change regularly, you need to track in your Git repo a reference to the right version of those files (a bit like lfs does for your large files, which are too stored elsewhere)


Those types of artifact are special in that you generally need only their latest version.
They can be managed in an independent referential. GitHub, for instance, manages its avatar through its own (historically) service gravatar.com.

That means what you are deploying should be:

  • reference to the avatar
  • a program able to fetch, after deployment, the avatar from their referential and copy/update them on the production server if needed.

这篇关于如何查找未由git跟踪的文件,然后重新同步这些文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 14:39