在当前目录的git stash之后,兄弟目录丢失了

时间:2017-07-07 18:11:53

标签: git git-stash

假设我有这样的目录结构:

project_root
|
+--parent
   |
   +--child
   |
   +--baby_brother

<access origin="*" allows-arbitrary-loads.../>是一个新目录,未被git攻击。我对baby_brother中的文件也进行了大量更改。我需要临时访问child中以前版本的文件,所以我想我只是隐藏我的更改:

child

然后:

cd $project_root/parent/child
git stash push .

现在,令我沮丧的是,cd $project_root/parent/child git stash pop 失踪了,还有一周的工作。 : - (

我有两个问题:

  1. 有没有办法让我的文件回来?我怀疑答案是“不”。

  2. 这是一个错误,还是我做错了什么?

  3. 我已经看到an SO question表示git删除未跟踪文件的预期行为,但是对于其中一个,它还说这在1.7.1.1(我正在使用2.13.0)中修复,并且二,我希望stash只影响baby_brother,因为我在该目录中并在命令末尾包含一个点来引用当前目录。

    这是一个快速重现,演示了这个问题:

    1 ~ % mkdir project_root
    2 ~ % cd project_root
    3 project_root % mkdir parent
    4 project_root % touch parent/file
    5 project_root % mkdir parent/child
    6 project_root % touch parent/child/file2
    7 project_root % git init
    Initialized empty Git repository in /home/pdaddy/project_root/.git/
    8 project_root % git add .
    9 project_root % git commit -m 'Get it in git'
    [master (root-commit) 2d0872c] Get it in git
     2 files changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 parent/child/file2
     create mode 100644 parent/file
    10 project_root % mkdir parent/baby_brother
    11 project_root % touch parent/baby_brother/file3
    12 project_root % touch parent/file4
    13 project_root % touch file5
    14 project_root % comment="As it turns out, file4 and file5 will be deleted, too."
    15 project_root % tree $PWD
    /home/pdaddy/project_root
    |-- file5
    `-- parent
        |-- baby_brother
        |   `-- file3
        |-- child
        |   `-- file2
        |-- file
        `-- file4
    
    3 directories, 3 files
    16 project_root % echo 'some changes' >> parent/child/file2
    17 project_root % cd parent/child
    18 child % git stash push .
    Saved working directory and index state WIP on master: 2d0872c Get it in git
    19 project_root % tree ~/project_root
    /home/pdaddy/project_root
    `-- parent
        |-- child
        |   `-- file2
        `-- file
    
    2 directories, 2 files
    20 child % git stash pop
    On branch master
    Changes not staged for commit:
      (use "git add ..." to update what will be committed)
      (use "git checkout -- ..." to discard changes in working directory)
    
            modified:   file2
    
    no changes added to commit (use "git add" and/or "git commit -a")
    Dropped refs/stash@{0} (80e41d0ed1f2b0a085d4f5ca3a38833a18873f98)
    21 child % tree ~/project_root
    /home/pdaddy/project_root
    `-- parent
        |-- child
        |   `-- file2
        `-- file
    
    2 directories, 2 files
    

1 个答案:

答案 0 :(得分:0)

我用git&#39; s next分支(v2.14.0.rc0)测试了我的repro示例,但问题并没有出现,所以我猜这是一个bug,有人有提出了修复。