0

我正在尝试在远程 Web 服务器上设置 GIT 存储库并将其连接到我的 Eclipse 上的项目,但在这样做时遇到了麻烦。我已经完成了我的功课并尝试了我能做的一切,但目前处于死胡同。

在远程服务器上创建存储库。在本地计算机上创建存储库。创建连接到本地计算机存储库的项目。尝试了所有方法来连接两个存储库。不可能的。

是的,这是我尝试过的方法之一。
我在远程服务器上创建了一个 git repo。
然后我导入了一个项目并提供了我的服务器信息以连接到 repo。
我能够连接,它为项目提供了我服务器上的所有文件。
我对文件进行了更改,然后转到“团队 > 阶段 > 提交 > 推送”。
我收到此错误'远程:错误:拒绝更新签出分支:refs/heads/master

remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error: 
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error: 
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ssh://sofiane@50.63.180.135/var/www/html/lms
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://sofiane@50.63.180.135/var/www/html/lms'

大约 8 小时后,我完全陷入了书呆子的愤怒,把我的键盘砸在墙上。引入流行的版本控制工具的好方法。

完美地说明了我的挫败感。与 Git 见鬼去吧。你好颠覆,我想你了。

4

2 回答 2

1

我认为您在服务器上创建了非裸存储库,这就是为什么您不能推送到已签出的同一分支的原因。

检查服务器上的存储库:

$ ls
repository

现在要么:

$ ls -a repository
.git
file1
file2
..

或者:

$ ls -a repository
HEAD
config
description
hooks
info
objects
packed-refs
refs

如果你得到第一个结果,你就有了一个非裸存储库。在服务器上将其克隆为裸机:

$ ls
repository
$ git clone --bare repository repository.git
$ mv repository oldrepository

然后尝试推动它。.git 扩展名是一个约定,表示一个裸存储库,存储库 url 不需要它。这意味着您的本地 git 存储库应使用其旧的远程配置。

于 2012-08-16T18:33:51.413 回答
0

您在 GIT 存储库视图中看到了什么?如果您可以在那里看到您的 GIT 存储库,那么您应该可以File -> Import... -> Projects from Git这样做:

在此处输入图像描述

于 2012-08-16T13:19:17.793 回答