Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 吉特+;ssh>;远程空、树和非裸_Git_Github_Ssh - Fatal编程技术网

Git 吉特+;ssh>;远程空、树和非裸

Git 吉特+;ssh>;远程空、树和非裸,git,github,ssh,Git,Github,Ssh,我尝试在loacl上使用git,并在生产上部署。 我还使用了括号和git插件 理想状态 [本地] 本地/我的/工作/文件夹 [remote 1] github [remote 2] remote2/my/server/folder/theme github的配置运行良好。 我的服务器遇到了一些困难。我使用ssh推送和连接到服务器 我在remote 2上做了什么 $ mkdir git/theme $ cd git/theme $ git init 我在本地所做的 git远程添加源ssh://u

我尝试在loacl上使用git,并在生产上部署。 我还使用了括号和git插件

理想状态

[本地] 本地/我的/工作/文件夹

[remote 1] github

[remote 2] remote2/my/server/folder/theme

github的配置运行良好。 我的服务器遇到了一些困难。我使用ssh推送和连接到服务器

我在remote 2上做了什么

$ mkdir git/theme
$ cd git/theme
$ git init
我在本地所做的 git远程添加源ssh://user@xxx.xx.xxx.xxx:yy/home/user/git/theme

开始时,我遇到一些错误:

remote: error: refusing to update checked out branch: 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'.
因此,我使用命令into/home/user/git/theme解决了这个问题:

$ git config receive.denyCurrentBranch ignore
但是我注意到,.git文件夹在推送时被更新了,但是没有本地/my/working/folder文件

我删除了Remote2上的所有想法,并启动了一个新的remote

最后,我得到以下配置:

[本地]

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "github"]
        url = git@github.com:me/theme.git
        fetch = +refs/heads/*:refs/remotes/github/*
[branch "master"]
        remote = github
        merge = refs/heads/master
[remote "origin"]
        url = ssh://user@xxx.xx.xxx.xxx:yy/home/user/git/theme/theme.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[remote 2]

[core]
        repositoryformatversion = 0
        filemode = true
        bare = true
当我使用

$ git push origin master
.git已更新,但没有一个文件被推送

在我开始的时候,我尝试了很多东西,但是我测试的所有芭蕾舞都不完美。我的本地和远程2之间的通信工作正常,这是一个良好的开端

首先,我混淆了裸存储库和非裸存储库

为什么当我推送到remote 2时,它不会推送我文件夹中的文件? 为什么本地分支主机上的主机连接到远程1? 为什么当我推到remote 2时,它推到分支原点/主节点而不是主节点

提前感谢您的帮助。 jB

为什么当我推送到remote 2时,它不会推送我文件夹中的文件


通过推送到远程存储库,您不推送文件,而只推送索引。裸存储库不包含文件(或跟踪文件)。当您尝试从其他地方克隆存储库时,您将看到您将获得所有文件。

据我所知,我必须在任何推送之前克隆存储库。。。但是如何克隆我的本地存储库呢?我无法从我的服务器(远程2)访问它?不。我没有告诉任何类似的事情。如果要创建新镜像,请创建新的裸机repo(
git init--bare
),并将其添加为[remote],然后将其推入其中(可能是
-force
push)。很抱歉让我感到困惑:当我推到github我的本地文件夹时,我注意到文件和.git正在更新。为什么服务器上的遥控器不能这样工作。我做了一个测试:在我的服务器上克隆github remote。在本地,当我推到我的服务器时,我会收到一条消息,所有内容都是最新的。当我对本地文件进行更改时,推送到服务器时会出现错误。我完全不明白。否则,我会考虑scp我的本地文件夹,但直到现在我遇到一个错误,无法解析主机名ssh。在github上,您看不到实际的文件,不是吗?您只看到web界面。对不起,我编辑了我的帖子。是的,我看到网站发生了变化。