I'm trying to make a local repo act as a remote with the name bak
for another local repo on my PC, using the following:
git remote add /home/sas/dev/apps/smx/repo/bak/ontologybackend/.git bak
which gives this error:
fatal: '/home/sas/dev/apps/smx/repo/bak/ontologybackend/.git' is not a valid remote name
I'm trying to sync two local repos, with one configured as a remote named bak
for the other, and then issuing git pull bak
.
What is the best way to do it?
Edit:
Sorry, silly me, I've just realized the remote add should be:
git remote add bak /home/sas/dev/apps/smx/repo/bak/ontologybackend/.git
the name of the remote goes before the address.
You have your arguments to the remote add
command reversed:
git remote add <NAME> <PATH>
So:
git remote add bak /home/sas/dev/apps/smx/repo/bak/ontologybackend/.git
See git remote --help
for more information.
If your goal is to keep a local copy of the repository for easy backup or for sticking onto an external drive or sharing via cloud storage (Dropbox, etc) you may want to use a bare repository. This allows you to create a copy of the repository without a working directory, optimized for sharing.
For example:
$ git init --bare ~/repos/myproject.git
$ cd /path/to/existing/repo
$ git remote add origin ~/repos/myproject.git
$ git push origin master
Similarly you can clone as if this were a remote repo:
$ git clone ~/repos/myproject.git
It appears that your format is incorrect:
If you want to share a locally created repository, or you want to take contributions from someone elses repository - if you want to interact in any way with a new repository, it's generally easiest to add it as a remote. You do that by running git remote add [alias] [url]. That adds [url] under a local remote named [alias].
#example
$ git remote
$ git remote add github git@github.com:schacon/hw.git
$ git remote -v
来源:https://stackoverflow.com/questions/10603671/how-to-add-a-local-repo-and-treat-it-as-a-remote-repo