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.

Saheel Godhane
  • 313
  • 4
  • 14

1 Answers1

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')
unutbu
  • 842,883
  • 184
  • 1,785
  • 1,677
  • 1
    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. – Saheel Godhane Feb 01 '15 at 18:03
  • 3
    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](https://github.com/gitpython-developers/GitPython/issues/70) and then consulting [the docs](http://gitpython.readthedocs.org/en/stable/tutorial.html) to find out more about `repo.git`. – unutbu Feb 01 '15 at 19:09
  • 2
    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. :) – Saheel Godhane Feb 02 '15 at 22:14