Setup common git location and work on any project from any location (Everything local)
Objective
Have a common place on local system to store all repositories. Work on any project from anywhere on local system and keep the updates (repo push) synced to common place.
We can then make google drive to backup the common repository folder 🙂
Steps
Common repo location
Identify the common location. Example: /Users/robin/GIT/java/
- Initialize bare repository
$git init --bare myproject.git
Project file location
Example: /tmp/myproject
From myproject location.
- Create a .gitignore file
- init local git repo
$git init
- add files to local git
$git add *
- commit files to local master
$git commit -a
- add remote location for bare repository
$git remote add common localhost:/Users/robin/GIT/java/myproject.git
- Push local master repo data to common location
$git push common master
From this time on, you can pull the code from common location into any directory.
<anydir>$git clone localhost:/Users/robin/GIT/java/myproject.git