Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitPython -- How to 'git stash' changes to a GitPython repository?

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.

like image 247
Saheel Godhane Avatar asked Feb 01 '15 17:02

Saheel Godhane


People also ask

How do I stash changes in local repository?

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.

How do you apply stashed changes?

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.

How do I stash specific files?

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.


1 Answers

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')
like image 140
unutbu Avatar answered Sep 20 '22 23:09

unutbu