4

I've got a git repo, and my colleague had a clone of that on his PC. For whatever reason, we've lost his repository due to technical issues.

A short while before we lost his repo, he stashed some work, and I did a git fetch followed by a git merge master.

Is it possible to get the content of the stash? Would the git fetch command have pulled the stash over as well?

I can view all the remote branches with git branch -a but I need the stashed data.

We're running git version 1.6.3.3 on Ubuntu 9.10 Karmic

Pete
  • 4,326
  • 9
  • 41
  • 75

1 Answers1

6

Sorry, I don't believe you can recover from this. (arguably, if you could, it would be a security risk; someone might have stashed a password inside of a configuration file or something.)

From the documentation (git fetch --help): Fetches named heads or tags from one or more other repositories, along with the objects necessary to complete them.

Key word: named heads. Sadly, the stash isn't a named head (or a tag).

mpontillo
  • 12,623
  • 7
  • 51
  • 87
  • Thanks for that, that explains it pretty well. This answer http://stackoverflow.com/a/5257371/197519 and this one http://stackoverflow.com/a/1550400/197519 also seem to state that you can't `fetch` stashes. I was being hopeful really. – Pete May 10 '12 at 15:20
  • // , Good answer. Would you mind including a link to a very brief explanation of what is (and, more relevant to this situation, what is **not**) a "named head" in Git bromenclature? – Nathan Basanese May 01 '17 at 19:28
  • @NathanBasanese, I'm not sure I have a good answer, but a named head would be anything in `.git/refs/*/**`. Normally you'll see things like `heads` (your local branches), `remotes`, your remote branches, and `tags`. The stash is stored similarly, in `.git/refs/stash`, but `git` will not allow you to push it anywhere. It's not something you've given a name... you've just stashed some random work. – mpontillo May 01 '17 at 22:52