6

I have my codebase in a git repo on my laptop and I setup a bare git repo on an external hard drive for my backup. I successfully pushed my first commit, but noticed my backup repo on my external hard drive does not show the files.

If my laptop crashes, how would I restore my full codebase? Was setting up as bare repo on my external hard drive incorrect?

Thanks Dusty

Dusty
  • 1,053
  • 2
  • 11
  • 24
  • 1
    Good job thinking of this _before_ your laptop crashes! You should be able to just clone from the bare repo like any other. – Neil Forrester Aug 02 '15 at 20:02

2 Answers2

9

Change into a new directory and run

git clone /bare/repo/dir.git

substituting the path for the real path of your bare repo. This will clone and check out the latest revision of your repository.

Maximillian Laumeister
  • 19,884
  • 8
  • 59
  • 78
  • Just curious, where was all this data in my bare repo? – Dusty Aug 02 '15 at 20:31
  • 1
    @Dusty The main difference between a normal and bare repo is that a normal repo is a folder files checked out and its entire history in the `.git` folder. A bare repo is just the entire history with no working copy checked out (in your `project.git` folder). [More details on how Git stores files](http://stackoverflow.com/a/8198276/2234742). – Maximillian Laumeister Aug 02 '15 at 20:34
2

You need to pull to your backup pc in order to receive the committed changes.

You can pull with the command: git pull.

However, it's not explicitly necessary to have a backup pc. After pushing, the changes are stored on both your own pc and the server where your repository is hosted. So you'll allready have two copies of the entire history of your project.

Mark Knol
  • 9,663
  • 3
  • 29
  • 44