I have the following repos.
- DEV REPO: in a directory on my development machine where i make changes
- MAIN REPO: bare repository on my development machine to which i push changes from dev repo
- PRODUCTION REPO: repository on host machine to pull updates from the main repo
I us开发者_如何学Goed git remote add origin /Users/me/sites/main_repo
to set the MAIN repo as origin for the DEV repo. The PRODUCTION repo is on a remote host. Can i use a variation of the same command to set the MAIN repo as origin for the PRODUCTION repo also? If "yes", then i suppose the syntax would include an ip address. What would that look like?
Using SSH
git remote add origin ssh://login@IP/path/to/repository
Using HTTP
git remote add origin http://IP/path/to/repository
However having a simple git pull
as a deployment process is usually a bad idea and should be avoided in favor of a real deployment script.
For anyone who comes here, as I did, looking for the syntax to change origin to a different location you can find that documentation here: https://help.github.com/articles/changing-a-remote-s-url/. Using git remote add
to do this will result in "fatal: remote origin already exists."
Nutshell:
git remote set-url origin https://github.com/username/repo
(The marked answer is correct, I'm just hoping to help anyone as lost as I was... haha)
You can include the branch to track when setting up remotes, to keep things working as you might expect:
git remote add --track master origin user@somesite.com:group/project.git # git
git remote add --track master origin user@172.16.1.100:group/project.git # git w/IP
git remote add --track master origin http://github.com/group/project.git # http
git remote add --track master origin http://172.16.1.100/group/project.git # http w/IP
git remote add --track master origin /Volumes/Git/group/project/ # local
git remote add --track master origin G:/group/project/ # local, Win
This keeps you from having to manually edit your git config or specify branch tracking manually.
精彩评论