Reputation: 26137
I have a production server with git-1.7.3.4_centos5.2 described here, and I have a local machine with git 1.7.7.1. What I need is a copy on local server where I can develop the site and upload it to the production server. There is another guy who can modify the content, so I need to pull the changes too. How can I solve that with git? (The most actual code is on my local machine now.)
I made some tests: I cloned an empty repo, and after that I modified the repo on the server. I could not download it with remote/download (git gui), but with checkout I had success. The push did not work also. How can I make them operational?
Upvotes: 1
Views: 1796
Reputation: 1327646
You should define two remotes:
What I need is a copy on local server where I can develop the site and upload it to the production server
That is a simple
git clone http://www.your_prod_server.com/git/your_bare_repo.git
That will clone the repo and define a remote named "origin". You will be able to push to it because it is a bare repo.
See "all about "bare" repos -- what, why, and how to fix a non-bare push".
See also "GIT: after push, remote repo shows files as deleted" for the danger of pushing to a non-bare repo:
When you push to a remote repo in Git, it does not update the working copy of that remote repo.
This means that the working copy will be out of sync with the last version that you pushed.
There is another guy who can modify the content, so I need to pull the changes too.
You need to add a remote pointing to the "other guy's repo address"
git remote add otherguy http://otherguy_server/other_guy_repo
Even if that colleague's repo isn't bare, you will be able to fetch from it, getting back his changes in your repo, and merging them in your local branch.
Upvotes: 1