There is a git-repository of the project, some files are added to .gitignore and thus exist only locally. Nevertheless, I want to keep some of these files under local version control, in order to track changes in them and be able to roll back in case anything happens. It seems like two separate (parallel) repositories are obtained, but with shared files and various .gitignore .

These special files are configs of various utilities that are included with the software. They are located, by definition, in different places, to create a single directory for them is not possible. The state of the configs does not need to be stored on the server and will be different for each user. But sometimes you want to track changes in these files locally and be able to quickly switch to this or that version.

How can you optimally control such files?

  • under local control - in 99% of cases, the git program works with local storage. - aleksandr barakin
  • @alexanderbarakin and in 99% of cases no control over ignored files is required. - αλεχολυτ
  • and you need to deploy this software to the server? - Mikhail Vaysman
  • @MikhailVaysman is not. Software is not a server at all. It is a complex of several separate applications that can nevertheless interact over a network. Changing configs is necessary in the process of developing, debugging and fixing bugs. - αλεχολυτ
  • why not use any configuration and deployment systems? ansible, chef, puppet - Mikhail Vaysman

1 answer 1

Suppose you have a repository with a main-repo project and a repository with files that exist only locally second-repo . Then inside main-repo you make a symbolic link to the file in second-repo . It turns out that main-repo ignores this file, and you keep the change history in second-repo .

Here is such a picture

. ├── main-repo │  ├── dir1 │  ├── .git │  ├── .gitignore │  └── ignore.txt -> ../second-repo/ignore.txt └── second-repo ├── .git └── ignore.txt 

In main-repo, the ignore.txt file is placed in .gitignore , and in second-repo , it is fully tracked.

  • It seems to be working. The only inconvenience is that you need to create a link to each file that requires control. - αλεχολυτ
  • @alexolut, so create a link to the directory. - aleksandr barakin
  • @alexanderbarakin files are in different folders, and besides, there are other files needed for the main repository. - αλεχολυτ
  • @alexolut, I explode: create links not to each file / directory, but combine all the “special” files / directories into one directory, and link to it. - aleksandr barakin
  • @alexolut can you describe how this situation arose? why the necessary files were in .gitignore ? Perhaps there is a more effective solution to this problem, but without an understanding of the situation it is difficult to tell. - Mikhail Vaysman