我和我的朋友和我一起在Internet上有一台服务器(可通过SSH提供)。我们已经开始使用git进行源控制。我们目前的设置如下:

  • 朋友在 servergit --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

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

谢谢!

有帮助吗?

解决方案

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

裸露的存储库是由

 git init --bare

如果您已经有一些版本的历史记录是裸露的克隆

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

至于您的警告,请参阅 这个问题.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top