Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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?

like image 652
MihaiG Avatar asked Sep 13 '16 13:09

MihaiG


People also ask

How do I create a git repository locally and push?

A common pattern when initializing a new repo is to go to a hosted Git service like Bitbucket and create a repo there. The service will provide a Git URL that you can then add to your local Git repository and git push to the hosted repo.

How do I push a local file to a git repository?

Create a GitHub repository for the existing project. Copy the GitHub URL for the new repo to the clipboard. Perform a git init command in the root folder of the existing project. Add all of the existing project's files to the Git index and then commit.


1 Answers

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.

like image 72
AnimiVulpis Avatar answered Nov 14 '22 04:11

AnimiVulpis