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?
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.
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.
Follow these steps:
Go to the folder you want to have your remote in
$ cd /path/to/my-remote
Create a bare repository there via git init
$ git init --bare
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With