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/

  1. Initialize bare repository
    $git init --bare myproject.git

 

Project file location

Example: /tmp/myproject

From myproject location.

  1. Create a .gitignore file
  2. init local git repo
    $git init
  3. add files to local git
    $git add *
  4. commit files to local master
    $git commit -a
  5. add remote location for bare repository
    $git remote add common localhost:/Users/robin/GIT/java/myproject.git
  6. 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

 

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *