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.
asked Feb 1, 2015 at 17:12
Saheel Godhane
3334 silver badges14 bronze badges
1 Answer 1
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')
answered Feb 1, 2015 at 17:25
unutbu
887k197 gold badges1.9k silver badges1.7k bronze badges
Sign up to request clarification or add additional context in comments.
5 Comments
Saheel Godhane
Thanks! I searched for "stash" in the docs but didn't find it, nor did I find any 'stash' function in the Repo class. And I missed this part of the documentation, hence the confusion.
unutbu
Since how you know is often more interesting than what you know, I'll mention that I found this by googling "gitpython stash", finding this bug report and then consulting the docs to find out more about
repo.git.Saheel Godhane
Thanks for that! I googled "how to stash gitpython repo" and similar queries, but I guess I was trying too hard to find an already existing Q/A post on some forum. Sometimes a minimalistic query like yours works better. :)
serv-inc
Do you have an idea why
repo.git.stash('show -p') does not work ?Mark A. Hershberger
Try
repo.git.stash('show', '-p')lang-py