How can I stash only one of multiple changed files on my branch?
相关问题
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
- Can I organize Git submodules in a flat hierarchy?
- Upload file > 25 MB on Github
相关文章
- 请教Git如何克隆本地库?
- GitHub:Enterprise post-receive hook
- Git Clone Fails: Server Certificate Verification F
- SSIS solution on GIT?
- Is there a version control system abstraction for
- ssh: Could not resolve hostname git: Name or servi
- Cannot commit changes with gitextensions
- git: retry if http request failed
Similar situation. Did commit and realized it's not ok.
Based on the answers this helped me.
I don't know how to do it on command line, only using SourceTree. Lets say you have changed file A, and have two change hunks in file B. If you want to stash only the second hunk in file B and leave everything else untouched, do this:
Save the following code to a file, for example, named
stash
. Usage isstash <filename_regex>
. The argument is the regular expression for the full path of the file. For example, to stash a/b/c.txt,stash a/b/c.txt
orstash .*/c.txt
, etc.Code to copy into the file:
I would use
git stash save --patch
. I don't find the interactivity to be annoying because there are options during it to apply the desired operation to entire files.Use
git stash push
, like this:For example:
This is available since Git 2.13, released in spring 2017.
I found no answer to be what I needed and that is as easy as:
This stashes exactly one file.