Git - pull&推送 - 生产服务器 [英] Git - pull & push - production server

查看:142
本文介绍了Git - pull&推送 - 生产服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台生产服务器,上面描述了这里,并且我有一台使用git 1.7.7.1的本地机器。我需要的是本地服务器上的副本,我可以开发该网站并将其上传到生产服务器。还有一个人可以修改内容,所以我也需要修改内容。我怎样才能解决这个问题? (最实际的代码现在在我的本地机器上。)

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.)

我做了一些测试:我克隆了一个空的回购站,之后我修改了服务器上的回购站。我无法通过远程/下载(git gui)下载它,但结帐时我已经成功了。推也没用。如何让它们运作?

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?

推荐答案

您应该定义两个遥控器:

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

这是一个简单的

git clone http://www.your_prod_server.com/git/your_bare_repo.git

这会克隆回购并定义名为origin的远程服务器。你将能够推动它,因为它是一个裸露的回购。

请参阅所有关于裸机回购 - 什么,为什么,以及如何解决非裸机推动

另请参阅 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:

当您在Git中推送到远程仓库时,它不会更新该远程仓库的工作副本。

这意味着工作副本将不会与您推送的最后一个版本。

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.

这篇关于Git - pull&推送 - 生产服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆