A
A
at0m1x2017-08-06 18:09:57
git
at0m1x, 2017-08-06 18:09:57

Git - how to add subfolders to a repository?

The project has a results folder and results/graphs nested in it.
Both the first and the second will contain files that should be ignored by git.
Both of these folders need to be added to the repository so that when cloned, these folders are also created immediately. There is a way to add a .gitignore file with content:

# Ignore everything in this directory
*
# Except this file
!.gitignore

If two such files are added to both results and results/graphs, then git will only see results, and graphs will ignore it and not add it to the repository, it’s understandable why.
How to solve the task?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Philipp, 2017-08-06
@zoonman

Put this file in both subdirectories and add it to tracking.
In a nested directory, you need to add .gitignore via an add force.
git add -f path/to/results/graphs/.gitignore

A
at0m1x, 2017-08-06
@at0m1x

I did this, added two .gitignore files to both folders, with the following content:
results/.gitignore

# Ignore everything in this directory
/*
# Except this file
!.gitignore
!graphs

results/graphs/.gitignore
# Ignore everything in this directory
*
# Except this file
!.gitignore

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question