# Why does git stash create two commits?

3 messages from 2012-01-30 to 2012-01-30. Participants: Phillip Susi, Seth Robertson, Junio C Hamano.
Thread: https://gitlist.dev/t/29483

## Phillip Susi, 2012-01-30 18:20

Subject: Why does git stash create two commits?
Message-ID: <4F26DF7B.7050109@ubuntu.com>
URL: https://gitlist.dev/e/4F26DF7B.7050109%40ubuntu.com

```
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

git stash makes two commits, one that has no changes from the base,
and one to stash your changes in.  Why?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJPJt97AAoJEJrBOlT6nu75G1cH/1qXXMFBPr5vGZbPXCCgG4eG
nmTVlVjxa9Wk52rY/o3NfrgDrftuKIeMdjrFxe/hOsuU37rfMUpWlGa6wtwOIgHL
Cm2s/+PssrOwpajb+v3h+0vqZGNULaxPNpApDjB4JWTxNs86aCV/+zkzoqNjO8y4
OfAZnzqe03BJmPjldvygswD0RMvRvBuHyGRVhTgATcc89yZmihFxCNyekHdVUSvD
zVIUgyUj1vlSRDnSJrtARbKR3JZQeTtN6rMLIOxN0T3iOkltMWFGMoVbJ23kiUyD
LuMSNMrBvvkEU6g6czqQNNyreSut/b1r1ZTt/pvF0qDWUE5CZ9Qhgs6Xz7prtWs=
=Yp0K
-----END PGP SIGNATURE-----

```

## Seth Robertson, 2012-01-30 18:25

Subject: Re: Why does git stash create two commits?
Message-ID: <201201301825.q0UIPLni016760@no.baka.org>
URL: https://gitlist.dev/e/201201301825.q0UIPLni016760%40no.baka.org
In-Reply-To: <4F26DF7B.7050109@ubuntu.com>

```

In message <4F26DF7B.7050109@ubuntu.com>, Phillip Susi writes:

    git stash makes two commits, one that has no changes from the base,
    and one to stash your changes in.  Why?

git-stash can make up to three commits:

working directory (of files git knows about)
index
working directory (of files git does not know about)

The third commit only appears if you use --all or --include-untracked.

Most likely you do not use -u/-a and your index has not been touched
yet, so you only see two commits, of which one is empty.

					-Seth Robertson

```

## Junio C Hamano, 2012-01-30 19:11

Subject: Re: Why does git stash create two commits?
Message-ID: <7vhazdatur.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vhazdatur.fsf%40alter.siamese.dyndns.org
In-Reply-To: <4F26DF7B.7050109@ubuntu.com>

```
Phillip Susi <psusi@ubuntu.com> writes:

> git stash makes two commits, one that has no changes from the base,
> and one to stash your changes in.  Why?

The only reason the former is identical to the base is because you are not
incrementally building your next commit using "git add". It represents the
state of your index. The latter represents the state of the tracked files
in your working tree.

```
