From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS53758 23.128.96.0/24 X-Spam-Status: No, score=-3.8 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 25B641F8C8 for ; Sun, 5 Sep 2021 17:16:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234711AbhIERRI (ORCPT ); Sun, 5 Sep 2021 13:17:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230471AbhIERRI (ORCPT ); Sun, 5 Sep 2021 13:17:08 -0400 Received: from mail-lj1-x234.google.com (mail-lj1-x234.google.com [IPv6:2a00:1450:4864:20::234]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC47FC061575 for ; Sun, 5 Sep 2021 10:16:04 -0700 (PDT) Received: by mail-lj1-x234.google.com with SMTP id m4so7119433ljq.8 for ; Sun, 05 Sep 2021 10:16:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=LuGLgg7bRSPaYIy+TjEL/Ls0JVaciTcNkvnQyc03W60=; b=mbWD7r8852BVH7SkmdIN+ITcR10XibroLQxEctWLLEOaZwYEw+IQrxnEiG76uQLmn3 kjPJljJzGxvg3mbYz4IsqfXo9p1KhgBvjmffJYCicaX2oBItIh0VRvVTI7R2pDzO2JyR MW2zjeujsNDO2DJZdqgjRngiL8Aw0j5/pjGt9IfjrivDjPsVFkmlp+9QiYJ0iYjTiRbq 1N7qs0qhjpVYzjOmMrxEbdV8DMJ5DNwCO6CoVbl1H///+QKWhzff5dfxy6kGY7MzliJb b+fmszr2vQjBGuR6GlGD1RYgo7/brsy8+QqPUve46sRQsgNAn7sf4CRq1A5rq/iOoOxS oDiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=LuGLgg7bRSPaYIy+TjEL/Ls0JVaciTcNkvnQyc03W60=; b=RFOTVl6ylkcaHcv8h2JnPZZaOVFJVzOgFxgwU+8K8BDGJebr79DKjzGQmftUmGjxVo Sqg+w5/11c2w8ikcxdc25TRmNNc5H1xmMWlCMD7wrrHYMkkEyE8+KHpLXoz3kkcfVu0u JW3NoypbfZxzX2t2BEYLYLdHAgCMDSftw6vX905BT/tfyfL+j48KYZnaAq7XGdRDowLX dCyzjsL9hQ5AiFgYVZFWaRZ/SbUPc7BMnuYdXDrNJHIBN5r/i2U8azcvlhXqJYH2Ydrl I0XCQ9sm2ZEifbaduxAKATr24nl1W3P40sA0ZQCBHOSyEF4lSY8lFolhN5AFWhbAiOSs 9x1g== X-Gm-Message-State: AOAM530nePU9s+K9WsunyyUNslw8nLcvgafE71K9u9ei+NRP3+nh0rS0 Ns0nt6rCpIoUuyXK4EAWrpWoEeyfU4AIc+aDqmItXGYO X-Google-Smtp-Source: ABdhPJy4OBrZDHwQTfXya4IntI0+mhaRAIUOo+up0Nrf8kmp6OB6X91I6lStOVTApzxMJZY0/f03WKoAA2s2tbfzsW0= X-Received: by 2002:a2e:7401:: with SMTP id p1mr7514675ljc.303.1630862162893; Sun, 05 Sep 2021 10:16:02 -0700 (PDT) MIME-Version: 1.0 References: <0e1f7a47-89e3-5f49-663e-bdd3e8efb6e5@rawbw.com> In-Reply-To: <0e1f7a47-89e3-5f49-663e-bdd3e8efb6e5@rawbw.com> From: Chris Torek Date: Sun, 5 Sep 2021 10:15:51 -0700 Message-ID: Subject: Re: stash push/pop unstages files? To: Yuri Cc: Git Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Sun, Sep 5, 2021 at 10:12 AM Yuri wrote: > In one sub-directory I altered some files, added a directory with files > and added the changes (git add .) > > Then I called 'git stash push && git stash pop'. > > After this the newly added directory remained in the staged status, but > altered files became unstaged. > > Is this an intended behavior? Yes. > Why stash push/pop unstages files? Shouldn't it preserve the directory > as-is? It does, *provided* you invoke the pop step with `--index`. When `git stash push` makes a stash, it saves both the index (staging area) and working tree, as two separate commits. Later, at the time you apply the saved stash, you choose whether to use the saved index / staging-area (`--index`) or to discard it (no `--index`). The apply step uses the saved working tree in all cases, and if you also stashed untracked files with `-u` or `-a`, it uses this third commit as well. The `pop` command is just `apply` followed by `drop` if the application succeeds. Chris