From: Ulrich Buchgraber <ulrich.b@gmx.at>
To: git@vger.kernel.org
Subject: Fwd: Data loss when using "git stash -u" and ignored content in directories
Date: Thu, 7 Apr 2016 22:34:37 +0200 [thread overview]
Message-ID: <CAGxq=N_Z6fWM9JLBwOHTDCRTy=CfmxqaPRUkwo-7a65Fgub_Nw@mail.gmail.com> (raw)
In-Reply-To: <CAGxq=N8C5YWYt_GMYVp6ZSoGkgEKhOikfUydwiD-Xm8zRD8qWA@mail.gmail.com>
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
parent reply other threads:[~2016-04-07 20:34 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <CAGxq=N8C5YWYt_GMYVp6ZSoGkgEKhOikfUydwiD-Xm8zRD8qWA@mail.gmail.com>]
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAGxq=N_Z6fWM9JLBwOHTDCRTy=CfmxqaPRUkwo-7a65Fgub_Nw@mail.gmail.com' \
--to=ulrich.b@gmx.at \
--cc=git@vger.kernel.org \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).