我正在尝试使用一系列单元测试进行预提交钩子,我想确保我的工作目录是干净的.编译需要很长时间,所以我希望尽可能利用重用编译的二进制文件.我的脚本遵循我在网上看到的例子:
# Stash changes
git stash -q --keep-index
# Run tests
...
# Restore changes
git stash pop -q
Run Code Online (Sandbox Code Playgroud)
这会导致问题.这是repro:
// Step 1到a.javagit add .// Step 2到a.javagit commit
git stash -q --keep-index #存储更改git stash pop -q #恢复更改此时我遇到了问题.该git stash pop -q显然有冲突,a.java我有
// Step 1
<<<<<<< Updated upstream
=======
// Step 2
>>>>>>> Stashed changes
Run Code Online (Sandbox Code Playgroud)
有没有办法让这个流畅干净?
我想隐藏未跟踪的文件,但我继续传递错误的选项.对我来说这听起来是对的:
git stash save [-a|--all]
Run Code Online (Sandbox Code Playgroud)
但实际上这也隐藏了文件.正确的是:
git stash save [-u|--include-untracked]
Run Code Online (Sandbox Code Playgroud)
当我运行git stash save -a并尝试git stash pop它时,我得到所有被忽略文件的无数错误:
path/to/file1.ext already exists, no checkout
path/to/file1.ext already exists, no checkout
path/to/file1.ext already exists, no checkout
...
Could not restore untracked files from stash
Run Code Online (Sandbox Code Playgroud)
所以命令失败了.
如何恢复跟踪和未跟踪的更改?git reflog不存储存储命令.