I'm new to git. Need some advise to know if my setup is correct. Please read below :
I'm using git for 2 separate projects on my development computer and want to backup everything on a USB drive (setup as a git bare repo). Additionally, I want to sync these projects on another computer (for deployment).
The 2 projects paths on computer1 are
/machine1/path/proj1
/machine1/path/proj2
This is how I've setup (repeated exact same steps for proj2)
#Initialize git repo
cd /machine1/path/proj1
git init
git add .
git commit -a -m "proj 1 first commit"
#Backup on USB
cd /usb/backup
mkdir proj1.git
cd proj1.git
git init --bare
cd /machine1/path/proj1
git push --mirror /usb/backup/proj1.git
#Clone to other computer
cd /machine2/path
git clone /usb/backup/proj1.git
#After making changes on machine1, I update machine2 using this command
git pull /usb/backup/proj1.git
Question:
- Are these steps correct for (i) setup, (ii) backup on USB, (iii) sync to other machines? Or is there a right/better way to do it ?
- I mistakenly executed these commands
cd /machine2/path/proj2
git pull /usb/backup/proj1.git
I expected git to show an error message ... something like "trying to sync proj2 with proj1 repo" but instead it created a subdirectory of proj2 inside proj1. Is there a shortcoming in my setup ? I expected an action like this would require a --force
switch or else produce a fatal error