I have a repo created via GitPython library that has some uncommitted changes. I want to stash those changes. How do I do it?
Searching for "stash" in the GitPython docs returned no results.
Bring the local repository to in sync with remote. git stash git pull origin <branch> git stash pop` Apply my stash changes. If you want to keep your stash on the stash list: git stash apply if you want to remove the stash from the stash list: git stash pop.
To retrieve changes out of the stash and apply them to the current branch you're on, you have two options: git stash apply STASH-NAME applies the changes and leaves a copy in the stash. git stash pop STASH-NAME applies the changes and removes the files from the stash.
To stash a specific file, use the “git stash push” command and specify the file you want to stash. However, the other tracked files that may be modified in your current working directory are untouched.
Per the docs, "Using git directly":
In case you are missing functionality as it has not been wrapped, you may conveniently use the git command directly. It is owned by each repository instance.
Thus, you could call git stash save
with
repo.git.stash('save')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With