代码之家  ›  专栏  ›  技术社区  ›  Jari Keinänen Roberto Canogar

当我将未跟踪的文件存储在Git中,但它没有使用Git stash pop还原时,我错过了什么选项?

  •  1
  • Jari Keinänen Roberto Canogar  · 技术社区  · 8 年前

    我同时测试了两件事,并具有如下工作树状态:

    Changes not staged for commit:
        modified:   component/file.html
        modified:   component/file.scss
        modified:   component/file.ts
        modified:   component2/file.scss
    
    Untracked files:
        common/file.scss
    

    我决定暂时隐藏所有scss文件,以关注其他具有 git stash push -m "scss files for later" -- *.scss 因此,我的工作树现在如下所示:

    Changes not staged for commit:
        modified:   component/file.html
        modified:   component/file.ts
    

    后来,我又把同样的藏品找了回来,但没有追踪的SCS(这是 显然地 隐藏)文件未弹出:

    Changes not staged for commit:
        modified:   component/file.html
        modified:   component/file.scss
        modified:   component/file.ts
        modified:   component2/file.scss
    

    当我弹出(vs.应用)隐藏时,隐藏参考现在不见了。

    我应该在流行音乐上加上某种标志吗?
    或者当我按下隐藏时,文件已经不存在了(意思是:我应该应用某种标志吗 推送时 )?

    (git版本2.15.0)


    在gist上复制的步骤: https://gist.github.com/keinajar/c52d90cded491f82ffbbf5939fc1b044

    参考要点:如果我尝试 git stash push -- common/d.scss 而不是 *.scss 我得到的错误(基于当前答案)将是预期结果:

    error: pathspec 'common/d.scss' did not match any file(s) known to git.
    Did you forget to 'git add'?
    

    所以这不是我遗漏的选项,而是一个bug?

    2 回复  |  直到 8 年前
        1
  •  3
  •   Rumid    8 年前

    要隐藏您需要使用的未跟踪文件 --include-untracked 标志(或 -u )根据 documentation 对于 push 命令

    关于这种奇怪的行为。是的,这是一个bug。你可以在这里找到更多信息 mailing list .

    正如上面所说:

    当前使用“git隐藏推送--”时,未跟踪的文件 与pathspec匹配的将被删除,即使最终不会 藏在任何地方。

        2
  •  0
  •   ephemerr    8 年前

    stash 不影响未跟踪的文件。你用它做了些什么 push 和 pop .

    推荐文章
    Omar  ·  Git合并错误
    9 年前