Re: Branches & directories
- From
- Hilco Wijbenga <hilco.wijbenga@gmail.com>
- Date
- Aug 17, 2011, 21:23 UTC
- Message-ID
- <CAE1pOi3rqqcz_6QxB8=g2jWOF-4SRZee7t8NXN1md2C4DL7wug@mail.gmail.com>
- In-Reply-To
- <7vvctvdf5r.fsf@alter.siamese.dyndns.org>
On 17 August 2011 12:14, Junio C Hamano <gitster@pobox.com> wrote:
Show 20 quoted lines
> Evan Shelhamer <shelhamer@imaginarynumber.net> writes: > >> (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. > > ... unless you have untracked files in test_dir/, that is. > > If the branch you are switching to does not have anything at test_dir, you > will not lose the untracked file because git does not remove test_dir/ nor > its untracked contents. > > Depending on what you have at the path "test_dir" in the branch you are > switching to, the actual rules are a bit more subtle than that, though.
Yes, I should have thought of that. The problem is with .gitignore. I have a number of files ignored that are important but can't be shared. So when I switch to 'master' the directory is not removed because it contains untracked, ignored files. And, of course, git status does not complain about them either because they are in .gitignore. :-)
This is still very annoying but hardly Git's fault (Git is working as intended). It would be really nice, though, if Git could somehow "stash" such files when checking out a different branch. In general, I would prefer if uncommitted changes and untracked and/or ignored files stuck to the branch where they were created. If I want to take them with me when I switch branches that should be possible but not the default behaviour. Is anything like that possible? Are there configuration options for this?