1

我在 Internet 上有一台服务器(可通过 ssh 获得),我和朋友使用它来共同开展项目。我们已经开始使用 git 进行源代码控制。我们目前的设置如下:

  • 朋友server使用git --bare init命名创建了存储库project.friend.git
  • 我克隆project.friend.gitserverproject.jesse.git
  • 然后我使用克隆project.jesse.gitserver我的本地机器上git clone jesse@server:/git_repos/project.jesse.git
  • 我在本地机器上工作并提交到本地机器。当我想将我的更改推送到project.jesse.gitserver使用的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

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

谢谢!

4

1 回答 1

4

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

裸存储库是用

 git init --bare

如果您已经有一些版本历史记录,请进行裸克隆

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

至于您的警告,请参阅此问题

于 2010-04-30T03:44:39.057 回答