.gitignore and git stash -u

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



We had been experiencing "random" deletions of files and directories,
and we finally figured out what they were: git stash -u.  A coworker
happened upon a webpage (after losing a weeks worth of experimental
work, back to his last backup), which described our problems exactly:

http://blog.icefusion.co.uk/git-stash-can-delete-ignored-files-git-stash-u/

The command git stash -u deletes ignored files from the hard drive..
very dangerous! Which leads me to my first question: Why does git
stash -u delete these files but a checkout doesn't? It seems
inconsistent.

We have the following in .gitignore, which is directly related to the
problems we're having (please note, we're using git on Windows, in
case that makes a syntax difference):

*/**/*
![Ss][Rr][Cc]/**/*

So what that does is ignores every file and subdirectory at the top
level, and then un-ignores Src/ and all files/dirs under that (we have
a few more that we unignore). The reason behind this is we have files
that are generated in the same tree as the source code, and
unfortunately it is infeasible to change that design. So, if someone
creates Data and puts their own custom configuration file it in, it
doesn't contaminate the repository. However, if course they don't want
to lose their configuration file either.

My understanding from the linked page is that our problem is having
the /* at the end which causes the files to be ignored and not the
directories themselves. However, I couldn't seem to find a combination
without the trailing /* that duplicated the functionality we had,  but
that prevented git stash from deleting our files. Can anyone provide
me with one? This is what I am really after.

I have come up with an inelegant workaround. If I add this line to .gitignore:

!Data/.placeholder

And then commit an empty .placeholder file, it seems to fix the
deletion problem. After that, we can place all sorts of untracked
files and sub-directories and they don't get deleted during a stash. I
guess it's because that tracked file keeps the directory "alive" in
some fashion, but I am not sure I understand why the sub-directories
are not deleted though, can anyone enlighten me on that? I would have
expected to have to put a .placeholder file in every sub-directory
under Data to prevent them from getting deleted too (because of the **
in the .gitignore line).

Another thing we were considering is modifying git itself to provide a
command-line option not to delete ignored files during a stash. Can
someone point me to the appropriate file?

Thanks a lot,
Jeff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]