Fwd: Data loss when using "git stash -u" and ignored content in directories

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

 



Hello,

A "git stash -u" cleans all untracked files (after storing them), and
normally does not clean ignored files.

But: It cleans ignored files within a directory, when the directory
itself is not ignored (e.g. a "dir/*" ignore filter) and untracked.

See the following reproduction sample. The last "ls" command shows
that the file "ignored_dir_with_star/ignored.txt" is lost.

    git init

    mkdir ignored_dir && touch ignored_dir/ignored.txt
    mkdir ignored_dir_with_star && touch ignored_dir_with_star/ignored.txt

    echo "/ignored_dir" >> .gitignore
    echo "/ignored_dir_with_star/*" >> .gitignore
    git add .gitignore
    git commit -m "added ignores"

    touch untracked.txt

    ls -R
    # => Output:
    # .:
    # ignored_dir/  ignored_dir_with_star/  untracked.txt
    #
    # ./ignored_dir:
    # ignored.txt
    #
    # ./ignored_dir_with_star:
    # ignored.txt

    git stash -u
    git stash pop

    ls -R
    # => Output:
    # .:
    # ignored_dir/  untracked.txt
    #
    # ./ignored_dir:
    # ignored.txt

Note that there is no data loss when instead using "git stash" or "git
stash -a".

(Tested with Git 2.8.1 on Ubuntu and Git for Windows version 2.8.1.windows.1.)

Ulrich
--
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]