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
In order to clone your repository to create a new bare repository, you run the clone command with the --bare option. By convention, bare repository directory names end with the suffix . git , like so: $ git clone --bare my_project my_project.
What is a bare repository? A bare repository is the same as default, but no commits can be made in a bare repository. The changes made in projects cannot be tracked by a bare repository as it doesn't have a working tree. A working tree is a directory in which all the project files/sub-directories reside.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With