I'm trying to do a pre-commit hook with a bare run of unit tests and I want to make sure my working directory is clean. Compiling takes a long time so I want to take advantage of reusing compiled binaries whenever possible. My script follows examples I've seen online:
# Stash changes git stash -q --keep-index # Run tests ... # Restore changes git stash pop -q
This causes problems though. Here's the repro:
- Add
// Step 1
toa.java
git add .
- Add
// Step 2
toa.java
git commit
git stash -q --keep-index
# Stash changes- Run tests
git stash pop -q
# Restore changes
At this point I hit the problem. The git stash pop -q
apparently has a conflict and in a.java
I have
// Step 1 <<<<<<< Updated upstream ======= // Step 2 >>>>>>> Stashed changes
Is there a way to get this to pop cleanly?
Read full article from githooks - How do I properly git stash/pop in pre-commit hooks to get a clean working tree for tests? - Stack Overflow
No comments:
Post a Comment