ZK Zhao
ZK Zhao

Reputation: 21613

Git: automatically add all files under a dir

Within my working dir, I have a lot of files:

file1.html
file2.html
file3.html
sub_dir1/
sub_dir2/
data/
output_result/

In this repo, not all files are under git, some are just supplementary files and I want to keep them aside. For example, file3.html is not under git, and some dataset within data are not under git.

When I working on it, I use git add -u, for updating changes on files already tracked by git. This is fine.

But now, I regularly output results into output_result/. So there are always new files in this dir. I want to update those files.

How can I add this file with ease?


git add -u is not sufficient anymore. I need to run git add output_result as well, and that feels repetitive.

I can add all untracked files into .gitignore, and then do it with git add .. But the problem is I have too many files that are not under git. (data/ folder has a lot of sub-folders.) Adding them manually is simply impossible.

Is there a .git-must-add-dir file that can help to autotrack the output_result/? So I don't have to add them by hand?

Upvotes: 0

Views: 190

Answers (1)

xdazz
xdazz

Reputation: 160963

Just adjust your .gitignore file like:

data/*

or if you want to ignore whole data directory, then just write as:

data

Upvotes: 1

Related Questions