M
M
Mikhail Belov2014-06-27 16:41:31
git
Mikhail Belov, 2014-06-27 16:41:31

How to ignore all files in git, except for a few located in different child directories?

Given: a folder with child folders, only a few hundred thousand files, the vast majority of which will definitely not change; at the root of this folder, a new git repository is raised, while empty; in the future, changes will be in several (completely different) folders, and these changes need to be tracked. There is no desire to add a huge bunch of static files, you only need to track what you need.
Task: what to write in .gitignore so as not to store the whole bunch of files, but to work with only a few of them?
Ideally, the solution should look something like this:

/*
!/first/change/for/tracking/file01.txt
!/second/small/change/file02.txt
# и так далее

But, unfortunately, git does not make it so easy. Instead of such an entry, it is proposed to ignore all files in each folder separately for each level, until I get to the final file:
/*
!/first
/first/*
!/first/change
/first/change/*
!/first/change/for
/first/change/for/*
!/first/change/for/tracking
/first/change/for/tracking/*
!/first/change/for/tracking/file01.txt

and so on for each file. the option is very dreary and long, taking into account the fact that the nesting can be quite deep, and there will be several dozen files, and they will be added during the development process. It's hard to write down this path for everyone. maybe there are some extensions that allow you to get by with little bloodshed and just specify the full path to each ignored file?
thank!

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
jcmvbkbc, 2014-06-27
@jcmvbkbc

raised a new git repository, empty for now; in the future, changes will be in several (completely different) folders, and these changes need to be tracked. There is no desire to add a huge bunch of static files, you only need to track what you need.

Do a git add only for files that need to be tracked and that's it. Don't write anything to .gitignore, you'll have 100500 untracked files and so on.

X
xandox, 2014-06-27
@xandox

 did you try it like that?
/**

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question