MihaiG
MihaiG

Reputation: 153

How to create a local push destination on a hard disk using Git

I want to make a local push destination on my hard disk on Git, and use that destination(folder) for push and pull instead of adding an remote repository. How do I do that in Git?

Upvotes: 15

Views: 6643

Answers (1)

AnimiVulpis
AnimiVulpis

Reputation: 2726

Follow these steps:

  1. Go to the folder you want to have your remote in

    $ cd /path/to/my-remote
    
  2. Create a bare repository there via git init

    $ git init --bare
    
  3. Go to the repository you want to work in and add a new remote pointing to the previously created repository via git remote add

    $ git remote add <name-of-remote> /path/to/my-remote
    
  4. After these steps you should be able to push to your new remote <name-of-remote>

    $ git push -u <name-of-remote> master
    

    Where -u is used to set the upstream of your branch, only needed the first time you push.

Upvotes: 30

Related Questions