public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox•com>
To: Jeffry Johnston <jeff@kidsquid•com>
Cc: git@vger•kernel.org
Subject: Re: .gitignore and git stash -u
Date: Tue, 22 Jul 2014 14:22:29 -0700	[thread overview]
Message-ID: <xmqqd2cxf5re.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <CAH4Lw1p4UUAH5LcrVEcXtr75Jdfp8osYN2vUk=nkAttosOOjDw@mail.gmail.com> (Jeffry Johnston's message of "Tue, 22 Jul 2014 13:55:01 -0700")

Jeffry Johnston <jeff@kidsquid•com> writes:

> 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!

Although I never use "stash --include-untracked" myself, I think it
is deliberate that the command removes all the untracked files.  The
author of that "feature" explains its use this way:

commit 787513027a7d0af3c2cd2f04b85bc7136d580586
Author: David Caldwell <david@porkrind•org>
Date:   Fri Jun 24 17:56:06 2011 -0700

    stash: Add --include-untracked option to stash and remove all untracked files
    
    The --include-untracked option acts like the normal "git stash save" but
    also adds all untracked files in the working directory to the stash and then
    calls "git clean --force --quiet" to restore the working directory to a
    pristine state.
    
    This is useful for projects that need to run release scripts. With this
    option, the release scripts can be from the main working directory so one
    does not have to maintain a "clean" directory in parallel just for
    releasing. Basically the work-flow becomes:
    
       $ git tag release-1.0
       $ git stash --include-untracked
       $ make release
       $ git clean -f
       $ git stash pop
    
    "git stash" alone is not enough in this case--it leaves untracked files
    lying around that might mess up a release process that expects everything to
    be very clean or might let a release succeed that should actually fail (due
    to a new source file being created that hasn't been committed yet).
    
    Signed-off-by: David Caldwell <david@porkrind•org>
    Signed-off-by: Junio C Hamano <gitster@pobox•com>

      reply	other threads:[~2014-07-22 21:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-22 20:55 .gitignore and git stash -u Jeffry Johnston
2014-07-22 21:22 ` Junio C Hamano [this message]

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqd2cxf5re.fsf@gitster.dls.corp.google.com \
    --to=gitster@pobox$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=jeff@kidsquid$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox