Restore Git from a local copy

6

2

We had a Git repo that was lost when the we forgot to back it up. One of us did a pull right before this happened and therefore has the latest code. Is it possible to rebuild the Git repo from a local copy of the sources? How?

Mridang Agarwalla

Posted 2011-07-24T09:20:42.180

Reputation: 617

Answers

5

Your local copy is a Git repository on its own, containing the entire commit history (although only of the master branch). Creating an empty repository in the old location (git init --bare whatever.git), then running git push from the local copy should be sufficient.

user1686

Posted 2011-07-24T09:20:42.180

Reputation: 283 655

2Depending on the configuration, you may wrong w.r.t. the master branch. For me all branches and tags get fetched. – maaartinus – 2012-06-10T10:40:37.653