通过ssh在私有服务器上使用github工作流程

时间:2010-04-30 03:36:52

标签: git workflow git-workflow

我在互联网上有一个服务器(通过ssh提供),我的朋友和我一起用于项目。我们已经开始使用git进行源代码控制。我们目前的设置如下:

  • 朋友在server上创建了一个名为git --bare init
  • project.friend.git的存储库
  • 我将project.friend.git上的server克隆到project.jesse.git
  • 然后我使用project.jesse.git
  • server git clone jesse@server:/git_repos/project.jesse.git克隆到我的本地计算机上
  • 我在本地计算机上工作并提交到本地计算机。当我想将更改推送到project.jesse.git server时,我使用git push origin master。我的朋友正在研究project.friend.git。当我想要进行更改时,我会pull jesse@server:/git_repos/project.friend.git

一切似乎都运转良好,但是,当我git push origin master时,我现在收到以下错误:

localpc:project.jesse jesse$ git push origin master
Counting objects: 100, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (76/76), done.
Writing objects: 100% (76/76), 15.98 KiB, done.
Total 76 (delta 50), reused 0 (delta 0)
warning: updating the current branch
warning: Updating the currently checked out branch may cause confusion,
warning: as the index and work tree do not reflect changes that are in HEAD.
warning: As a result, you may see the changes you just pushed into it
warning: reverted when you run 'git diff' over there, and you may want
warning: to run 'git reset --hard' before starting to work to recover.
warning: 
warning: You can set 'receive.denyCurrentBranch' configuration variable to
warning: 'refuse' in the remote repository to forbid pushing into its
warning: current branch.
warning: To allow pushing into the current branch, you can set it to 'ignore';
warning: but this is not recommended unless you arranged to update its work
warning: tree to match what you pushed in some other way.
warning: 
warning: To squelch this message, you can set it to 'warn'.
warning: 
warning: Note that the default will change in a future version of git
warning: to refuse updating the current branch unless you have the
warning: configuration variable set to either 'ignore' or 'warn'.
To jesse@server:/git_repos/project.jesse.git
   c455cb7..e9ec677  master -> master

这个警告是否需要我担心?就像我说的,一切似乎都在起作用。我的朋友可以从我的分支机构中取出我的更改。我在服务器上有克隆,因此他可以访问它,因为他无法访问我的本地计算机。有什么可以做得更好吗?

谢谢!

1 个答案:

答案 0 :(得分:4)

您应该在服务器上设置 bare 存储库。裸存储库仅包含通常位于存储库根目录的.git目录中的版本历史信息。你可以从它那里克隆或者像任何其他存储库一样推送它。

使用

创建裸存储库
 git init --bare

如果您已经有一些版本历史记录,请制作一个裸克隆

git clone --bare git://some/where

至于您的警告,请参阅this question