Re: Deleted folder keeps showing up?
- From
Benjamin Buch <benni.buch@gmx.de>
- Date
- Sep 7, 2009, 08:17 UTC
- Message-ID
- <53F9526D-E31D-4027-8871-8468AB476E6D@gmx.de>
- In-Reply-To
- <7vfxb3yuma.fsf@alter.siamese.dyndns.org>
Hi Junio,
thanks for the explanation!
It made things a lot clearer for me. And I think that could be exactly what happened and the reason why I couldn't reproduce the 'error'.
-benjamin
Am 04.09.2009 um 10:36 schrieb Junio C Hamano:
Show 78 quoted lines
> Benjamin Buch <benni.buch@gmx.de> writes: > >> Strangely, I can't reproduce the error today. > > If a branch has dir/file tracked, and another branch does not have > anything tracked in dir/ directory at all, then switching from the > former > branch to the latter can remove dir/ only when you do not have any > untracked files in there when you switch. Otherwise dir/ must stay > behind to keep the untracked files. > > You can see it by a simple experiment. > > $ rm -fr trial > $ mkdir trial > $ cd trial > $ git init > $ >elif > $ git commit -m initial > $ git branch lacksdir > $ mkdir dir > $ >dir/file > $ git add dir/file > $ git commit -m add-dir-file > > Now, after this set-up, your 'master' has dir/file and 'lacksdir' does > not have anything tracked in dir/ directory. > > Observe: > > $ git checkout lacksdir > $ find ??* > elif > $ git checkout master > $ find ??* > dir > dir/file > elif > $ >dir/garbage > $ git checkout lacksdir > $ find ??* > dir > dir/garbage > elif > > If switching to 'lacksdir' removed the dir/ directory, whatever was > in the > untracked file dir/garbage will be lost. In the above exercise, I > named > it garbage, so a casual reader might get a false impression that it > should > be thrown away, but in real life workflow, it often happens that > > (1) you start doing some interesting experimental changes, while on > 'master'; > > (2) you realize that this change does not belong to 'master', but > belongs > to some other branch, perhaps 'lacksdir'; > > (3) you switch to the branch, to keep working. > > Remember that, in git, your uncommitted changes to the index and the > work > tree do not belong to the branch. They try to follow you across > branch > switching. Since untracked new files are something potentially you > might > want to add after branch switching, we do not remove them. And > because we > choose not to remove dir/file, even though the commit at the tip of > the > lacksdir branch does not have anything tracked in dir/ directory, we > cannot remove it from the work tree. > -- > 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