{"thread":{"id":"30136","subject":"How to add folder NON RECURSIVELY ?","startedAt":"2012-04-03T12:01:11Z","lastAt":"2012-04-04T06:52:24Z","messageCount":6,"participants":["J. Bakshi","Matthieu Moy","Dirk Süsserott"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"188404","messageId":"20120403173111.5329d7ed@shiva.selfip.org","threadId":"30136","inReplyTo":null,"subject":"How to add folder NON RECURSIVELY ?","fromName":"J. Bakshi","fromEmail":"joydeep.bakshi@infoservices.in","sentAt":"2012-04-03T12:01:11Z","receivedAt":"2012-04-03T12:01:11Z","isPatch":false,"sender":{"key":"joydeep.bakshi@infoservices.in","avatar":null},"body":"Hello,\n\nPlease consider the following folder structure\n\n` `  `  `\nfoo/\n\nfoo/dir1/file1\n\nfoo/dir2/file2\nfoo/dir2/file3\n\n` ` ` ` ` ` ` \n\nI like to add the folder structure in a way that only foo/dir1/file1 is added to\nthe git. foo/dir2 and foo/dir3 should be added to the git also to show the directory\nstructure and not the contents of those folder.\n\nIt is easy in SVN by --non-recursive switch, but how can I do this in git with .gitignore ?\n\nThanks\n\nBTW: Please CC to me\n"},{"id":"188405","messageId":"vpqzkatc915.fsf@bauges.imag.fr","threadId":"30136","inReplyTo":"20120403173111.5329d7ed@shiva.selfip.org","subject":"Re: How to add folder NON RECURSIVELY ?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-04-03T12:08:38Z","receivedAt":"2012-04-03T12:08:38Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"J. Bakshi\" <joydeep.bakshi@infoservices.in> writes:\n\n> I like to add the folder structure in a way that only foo/dir1/file1 is added to\n> the git. foo/dir2 and foo/dir3 should be added to the git also to show\n> the directory\n> structure and not the contents of those folder.\n\nGit doesn't record the existance of directories. For Git, a directory\nexists if and only if it has some files in it. So, \"foo/dir2 and\nfoo/dir3 should be added to the git\" cannot be done in Git.\n\nA common workaround is to create a dummy file, typically .gitignore,\nwithin the directories you want to add. Depending on the intended use of\nthe directory, you may want this file to be empty (to tell your\ncollaborators \"there's nothing here for now, but there will be later\"),\nor to contain '*' to mean \"there will never be any tracked files in this\ndirectory\".\n\nIOW,\n\ntouch foo/dir2/.gitignore foo/dir3/.gitignore\ngit add foo/dir2/.gitignore foo/dir3/.gitignore\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"188408","messageId":"201204031223.q33CMvQC004186@VM-MailSafe-02.soltecsis.com","threadId":"30136","inReplyTo":"vpqzkatc915.fsf@bauges.imag.fr","subject":"Re: How to add folder NON RECURSIVELY ?","fromName":"J. Bakshi","fromEmail":"joydeep.bakshi@infoservices.in","sentAt":"2012-04-03T12:22:47Z","receivedAt":"2012-04-03T12:22:47Z","isPatch":false,"sender":{"key":"joydeep.bakshi@infoservices.in","avatar":null},"body":"On Tue, 03 Apr 2012 14:08:38 +0200\nMatthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n\n> \"J. Bakshi\" <joydeep.bakshi@infoservices.in> writes:\n> \n> > I like to add the folder structure in a way that only foo/dir1/file1 is added to\n> > the git. foo/dir2 and foo/dir3 should be added to the git also to show\n> > the directory\n> > structure and not the contents of those folder.\n> \n> Git doesn't record the existance of directories. For Git, a directory\n> exists if and only if it has some files in it. So, \"foo/dir2 and\n> foo/dir3 should be added to the git\" cannot be done in Git.\n> \n> A common workaround is to create a dummy file, typically .gitignore,\n> within the directories you want to add. Depending on the intended use of\n> the directory, you may want this file to be empty (to tell your\n> collaborators \"there's nothing here for now, but there will be later\"),\n> or to contain '*' to mean \"there will never be any tracked files in this\n> directory\".\n> \n> IOW,\n> \n> touch foo/dir2/.gitignore foo/dir3/.gitignore\n> git add foo/dir2/.gitignore foo/dir3/.gitignore\n> \n\nThanks for your suggestion.\nSo .gitignore for foo/dir2/  and  foo/dir3/ should add those directories non recursively.\n\nCould you please suggest how can I add foo/dir1/file1 ?\n\nguess\n\ntouch foo/dir1/.gitignore\ngit add foo/dir1/\ngit add foo/dir1/file1\n\n??\n"},{"id":"188411","messageId":"4F7AF740.9070906@dirk.my1.cc","threadId":"30136","inReplyTo":"201204031223.q33CMvQC004186@VM-MailSafe-02.soltecsis.com","subject":"Re: How to add folder NON RECURSIVELY ?","fromName":"Dirk Süsserott","fromEmail":"newsletter@dirk.my1.cc","sentAt":"2012-04-03T13:12:32Z","receivedAt":"2012-04-03T13:12:32Z","isPatch":false,"sender":{"key":"newsletter@dirk.my1.cc","avatar":null},"body":"Am 03.04.2012 14:22 schrieb J. Bakshi:\n> On Tue, 03 Apr 2012 14:08:38 +0200\n> Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n> \n>> \"J. Bakshi\" <joydeep.bakshi@infoservices.in> writes:\n>>\n>>> I like to add the folder structure in a way that only foo/dir1/file1 is added to\n>>> the git. foo/dir2 and foo/dir3 should be added to the git also to show\n>>> the directory\n>>> structure and not the contents of those folder.\n>>\n>> Git doesn't record the existance of directories. For Git, a directory\n>> exists if and only if it has some files in it. So, \"foo/dir2 and\n>> foo/dir3 should be added to the git\" cannot be done in Git.\n>>\n>> A common workaround is to create a dummy file, typically .gitignore,\n>> within the directories you want to add. Depending on the intended use of\n>> the directory, you may want this file to be empty (to tell your\n>> collaborators \"there's nothing here for now, but there will be later\"),\n>> or to contain '*' to mean \"there will never be any tracked files in this\n>> directory\".\n>>\n>> IOW,\n>>\n>> touch foo/dir2/.gitignore foo/dir3/.gitignore\n>> git add foo/dir2/.gitignore foo/dir3/.gitignore\n>>\n> \n> Thanks for your suggestion.\n> So .gitignore for foo/dir2/  and  foo/dir3/ should add those directories non recursively.\n> \n> Could you please suggest how can I add foo/dir1/file1 ?\n> \n> guess\n> \n> touch foo/dir1/.gitignore\n> git add foo/dir1/\n> git add foo/dir1/file1\n> \n\nAlmost ;-)\n\nSince foo/dir1 already contains file1 there's no need to add a\n.gitignore in dir1 (except, of course, you really want to ignore sth. in\nthat directory).\n\nIf this is your directory structure:\n\nfoo/dir1/file1\nfoo/dir2\nfoo/dir3\n\nfoo/dir1/ is automatically added when you \"git add foo/dir1/file1\".\nTo add the (empty) directories dir2 and dir3 you need some placeholder\nfile in them because git does not track directories, only files\n(together with their path).\n\nThus:\n\ntouch foo/dir2/.gitignore\ntouch foo/dir3/.gitignore\ngit add foo/dir2/.gitignore\ngit add foo/dir3/.gitignore\n\nIf you add a directory (like \"git add foo/dir1/) git will add all files\nin that directory (recursively), again, except for empty directories.\n\n\nHTH,\n\tDirk\n"},{"id":"188410","messageId":"vpqaa2tc5xi.fsf@bauges.imag.fr","threadId":"30136","inReplyTo":"201204031223.q33CMvQC004186@VM-MailSafe-02.soltecsis.com","subject":"Re: How to add folder NON RECURSIVELY ?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2012-04-03T13:15:37Z","receivedAt":"2012-04-03T13:15:37Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"\"J. Bakshi\" <joydeep.bakshi@infoservices.in> writes:\n\n> Could you please suggest how can I add foo/dir1/file1 ?\n>\n> guess\n>\n> touch foo/dir1/.gitignore\n> git add foo/dir1/\n\nNot if you want only \"file1\" to be added. As I said, Git doesn't know\nand doesn't want to know about directories. So \"git add directory/\" is\njust a shorthand that adds all (non-ignored) files in this directory.\n\n> git add foo/dir1/file1\n\nThis last line alone will do it.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"188471","messageId":"201204040652.q346qaC8020941@VM-MailSafe-02.soltecsis.com","threadId":"30136","inReplyTo":"vpqaa2tc5xi.fsf@bauges.imag.fr","subject":"Re: How to add folder NON RECURSIVELY ?","fromName":"J. Bakshi","fromEmail":"joydeep.bakshi@infoservices.in","sentAt":"2012-04-04T06:52:24Z","receivedAt":"2012-04-04T06:52:24Z","isPatch":false,"sender":{"key":"joydeep.bakshi@infoservices.in","avatar":null},"body":"On Tue, 03 Apr 2012 15:15:37 +0200\nMatthieu Moy <Matthieu.Moy@grenoble-inp.fr> wrote:\n\n> \"J. Bakshi\" <joydeep.bakshi@infoservices.in> writes:\n> \n> > Could you please suggest how can I add foo/dir1/file1 ?\n> >\n> > guess\n> >\n> > touch foo/dir1/.gitignore\n> > git add foo/dir1/\n> \n> Not if you want only \"file1\" to be added. As I said, Git doesn't know\n> and doesn't want to know about directories. So \"git add directory/\" is\n> just a shorthand that adds all (non-ignored) files in this directory.\n> \n> > git add foo/dir1/file1\n> \n> This last line alone will do it.\n> \n\nThanks a lot to all of you for your valuable suggestion.\n"}]}