Thread (3 messages) flat view 3 messages, 3 authors, 2016-06-15

Re: How to add folder NON RECURSIVELY ?

From: Matthieu Moy <hidden>
Date: 2016-06-15 22:53:27

"J. Bakshi" [off-list ref] writes:
I like to add the folder structure in a way that only foo/dir1/file1 is added to
the git. foo/dir2 and foo/dir3 should be added to the git also to show
the directory
structure and not the contents of those folder.
Git doesn't record the existance of directories. For Git, a directory
exists if and only if it has some files in it. So, "foo/dir2 and
foo/dir3 should be added to the git" cannot be done in Git.

A common workaround is to create a dummy file, typically .gitignore,
within the directories you want to add. Depending on the intended use of
the directory, you may want this file to be empty (to tell your
collaborators "there's nothing here for now, but there will be later"),
or to contain '*' to mean "there will never be any tracked files in this
directory".

IOW,

touch foo/dir2/.gitignore foo/dir3/.gitignore
git add foo/dir2/.gitignore foo/dir3/.gitignore

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help