GitPython -- How to 'git stash' changes to a GitPython repository?
Asked Answered
E

1

11

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.

Exhibition answered 1/2, 2015 at 17:12 Comment(0)
I
16

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')
Isologous answered 1/2, 2015 at 17:25 Comment(3)
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.Exhibition
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.Isologous
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. :)Exhibition

© 2022 - 2024 — McMap. All rights reserved.