git-stash

How do I properly git stash/pop in pre-commit hooks to get a clean working tree for tests?

早过忘川 提交于 2019-11-26 02:02:10
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 to a.java git add . Add // Step 2 to a.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.

git stash and apply

守給你的承諾、 提交于 2019-11-26 01:58:28
问题 I\'m new to git and not quite clear on how stashing works. Let\'s say I\'m working on branch master and try to git pull and receive the error that my local changes would be overwritten and need to be stashed or committed. If I haven\'t staged any of my changes and run git stash , then do a git pull and and update successfully, what happens when I git stash apply ? In general, If someone else modifies files and I run git pull , what happens when I run git stash apply ? does it overwrite the

How do I properly git stash/pop in pre-commit hooks to get a clean working tree for tests?

穿精又带淫゛_ 提交于 2019-11-26 01:08:30
问题 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 to a.java git add . Add // Step 2 to a.java git commit git stash -q -

Move existing, uncommitted work to a new branch in Git

吃可爱长大的小学妹 提交于 2019-11-26 00:56:20
问题 I started some work on a new feature and after coding for a bit, I decided this feature should be on its own branch. How do I move the existing uncommitted changes to a new branch and reset my current one? I want to reset my current branch while preserving existing work on the new feature. 回答1: Use the following: git checkout -b <new-branch> This will leave your current branch as is, create and checkout a new branch and keep all your changes. You can then make a commit with: git add <files>

How to recover from “git stash save --all”?

牧云@^-^@ 提交于 2019-11-26 00:26:01
问题 I wanted to stash untracked files, but I keep passing the wrong option. To me this sounds right: git stash save [-a|--all] but this in fact stashes ignored files as well. The correct one is: git stash save [-u|--include-untracked] When I run git stash save -a and try to git stash pop it, I get countless errors for all ignored files: 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

Can “git pull” automatically stash and pop pending changes?

亡梦爱人 提交于 2019-11-25 22:05:15
问题 I know how to solve this: user@host$ git pull Updating 9386059..6e3ffde error: Your local changes to the following files would be overwritten by merge: foo.bar Please, commit your changes or stash them before you can merge. Aborting But isn\'t there a way to let git pull do the stash and pop dance for me? If this command has a different name, it\'s ok. Creating a shell alias for git stash; git pull; git stash pop is a solution, but I search for a better solution. 回答1: For Git 2.6+ (released

How to recover a dropped stash in Git?

随声附和 提交于 2019-11-25 22:00:20
问题 I frequently use git stash and git stash pop to save and restore changes in my working tree. Yesterday I had some changes in my working tree that I had stashed and popped, and then I made more changes to my working tree. I\'d like to go back and review yesterday\'s stashed changes, but git stash pop appears to remove all references to the associated commit. I know that if I use git stash then .git/refs/stash contains the reference of the commit used to create the stash. And .git/logs/refs