From: Evan Shelhamer <shelhamer@imaginarynumber.net>
To: Hilco Wijbenga <hilco.wijbenga@gmail.com>
Cc: Git Users <git@vger.kernel.org>
Subject: Re: Branches & directories
Date: Wed, 17 Aug 2011 14:47:02 -0400 [thread overview]
Message-ID: <CABNdCrCbSqup1=D2eEbGDhw3JzZGYHWLVqZFsB6GDO4Vk7HRxg@mail.gmail.com> (raw)
In-Reply-To: <CAE1pOi3Eg88i+1s+CcW3+W0WNZ-NYUQb1EV55oh+g1Od78AByQ@mail.gmail.com>
Hey Hilco,
I'm not sure exactly what you did because you didn't give a list of
git commands, but I'm guessing you ran into the fact that git doesn't
track empty directories.
For instance if I do:
(in repo on your branch)
mkdir test_dir
touch test_file
git add *
git commit -m "test commit"
test_file will be tracked but test_dir will not (because it is empty).
To avoid this problem, a convention is to add an empty ".gitkeep" file
to directories. For example:
(in repo on your branch)
mkdir test_dir
touch test_dir/.gitkeep
touch test_file
git add *
git commit -m "test commit (with directory)"
Will commit the directory as expected in your branch, and when you go
to checkout another branch it will not exist.
Hope that helps. Sorry if you already know this and I misunderstood
your question.
Evan Shelhamer
On Wed, Aug 17, 2011 at 2:35 PM, Hilco Wijbenga
<hilco.wijbenga@gmail.com> wrote:
> Hi all,
>
> I have been noticing strange behaviour that I would like to be able to
> explain or report as a bug as the case may be.
>
> What happens is that I create and commit a new directory in branch
> 'next' and then when I checkout 'master' this new directory is still
> there. I think this is wrong as this new directory does not exist yet
> in 'master'. Is my understanding correct?
>
> I tried recreating this scenario in a clean Git repo with a simple
> mkdir and commit but when I did a checkout of 'master' the new
> directory was removed. So the basic scenario seems to work the way I
> expect it to.
>
> Assuming I ran into a bug, I would like some suggestions to properly
> investigate this. Clearly, I'm doing something else that triggers the
> behaviour I'm seeing but I'm not sure what it is. What might trigger
> Git "remembering" a directory? Or what would prevent it from removing
> a directory when checking out a different branch?
>
> Extra information: "git status" (in 'master') yields nothing. But
> after adding a new file in the directory-that-should-not-be-there, Git
> treats the entire directory as untracked and new (as one would
> expect). I can also safely remove the directory with no (obvious) ill
> effects.
>
> Cheers,
> Hilco
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2011-08-17 18:47 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-17 18:35 Branches & directories Hilco Wijbenga
2011-08-17 18:47 ` Evan Shelhamer [this message]
2011-08-17 19:14 ` Junio C Hamano
2011-08-17 21:23 ` Hilco Wijbenga
2011-08-18 4:45 ` Jonathan Nieder
2011-08-21 19:48 ` Hilco Wijbenga
2011-08-18 5:52 ` Michael Witten
2011-08-18 10:56 ` Michael J Gruber
2011-08-18 17:49 ` Michael Witten
2011-08-19 0:13 ` Jonathan Nieder
2011-08-21 20:25 ` Hilco Wijbenga
2011-08-21 20:53 ` Michael Witten
2011-08-21 21:37 ` Hilco Wijbenga
2011-08-21 23:06 ` Michael Witten
2011-08-21 23:35 ` Hilco Wijbenga
2011-08-22 0:07 ` Michael Witten
2011-08-22 0:47 ` Hilco Wijbenga
2011-08-22 1:53 ` Hilco Wijbenga
2011-08-22 2:05 ` Michael Witten
2011-08-22 2:13 ` Hilco Wijbenga
2011-08-22 3:01 ` Kyle Moffett
2011-08-22 5:36 ` Hilco Wijbenga
2011-08-22 12:46 ` Kyle Moffett
2011-08-22 18:49 ` Hilco Wijbenga
2011-08-22 19:31 ` Kyle Moffett
2011-08-22 20:10 ` Hilco Wijbenga
2011-08-22 21:01 ` Restoring timestamps (Re: Branches & directories) Jonathan Nieder
2011-08-22 22:33 ` Hilco Wijbenga
2011-08-22 23:21 ` Jonathan Nieder
2011-08-23 3:06 ` Hilco Wijbenga
2011-08-23 3:20 ` Hilco Wijbenga
2011-10-02 15:06 ` Enrico Weigelt
2011-10-02 22:29 ` Hilco Wijbenga
[not found] ` <CA+sFfMf=gi5CWyfZEt-Nmdr4J9g__maQTqy1WePr1x8D-AVr4A@mail.gmail.com>
2011-10-02 22:25 ` Hilco Wijbenga
2011-08-23 14:46 ` Branches & directories Michael Witten
2011-10-02 16:57 ` Robin Rosenberg
2011-10-02 17:31 ` Ronan Keryell
2011-10-02 19:09 ` Matthieu Moy
2011-10-02 23:45 ` Hilco Wijbenga
2011-10-02 23:40 ` Hilco Wijbenga
2011-10-03 3:07 ` Jeff King
2011-10-03 7:15 ` Hilco Wijbenga
2011-10-03 7:30 ` Jeff King
2011-10-03 7:32 ` Matthieu Moy
2011-10-03 7:34 ` Jeff King
2011-10-03 7:41 ` Matthieu Moy
2011-10-03 7:44 ` Jeff King
2011-10-03 7:48 ` Junio C Hamano
2011-10-03 7:51 ` Jeff King
2011-10-03 17:31 ` Hilco Wijbenga
2011-10-03 14:59 ` Robin Rosenberg
2011-10-03 17:20 ` Hilco Wijbenga
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CABNdCrCbSqup1=D2eEbGDhw3JzZGYHWLVqZFsB6GDO4Vk7HRxg@mail.gmail.com' \
--to=shelhamer@imaginarynumber.net \
--cc=git@vger.kernel.org \
--cc=hilco.wijbenga@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.