我正在开发Intranet Web应用程序,因此无法以某种方式将其推送到本地Web服务器。找到的解决方案是在本地Web服务器上创建git服务器。但是,我是git的新手,无法将代码推送到本地存储库中。
这是我所做的:
/var/www/html
上寻找Web应用程序,我不得不手动将其复制到administrador用户(也许我在这里错了吗?)/var/www/html/asc
上创建了一个目录,然后首先尝试git init --bare
,它将asc文件夹转为.git文件夹。我发现这很奇怪,因为我以前的所有项目上都有一个.git文件夹,因此我删除了所有内容,并做了git init
在/var/www/html/asc
目录内创建了一个.git文件夹(这就是我所期望的) )。git init
-> git -am 'initial commit'
-> git remote add localgit administrator@192.168.0.106:/var/www/html/asc
-> git push localgit master
但这会给我以下错误:
Counting objects: 132, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (120/120), done.
Writing objects: 100% (132/132), 2.02 MiB | 7.70 MiB/s, done.
Total 132 (delta 13), reused 0 (delta 0)
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'.
To 192.168.0.106:/var/www/html/asc/.git
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'administrador@192.168.0.106:/var/www/html/asc/.git'
现在,当我尝试使用--bare
标签(对我来说很奇怪)进行设置时将代码推送到本地git服务器时,这就是我得到的消息:
Counting objects: 132, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (120/120), done.
Writing objects: 100% (132/132), 2.02 MiB | 7.56 MiB/s, done.
Total 132 (delta 13), reused 0 (delta 0)
To 192.168.0.106:/var/www/html/asc
[new branch] master -> master
但是,在Web服务器上,目录/var/www/html/asc
包含所有git内容,例如分支,HEAD,hook,信息等。但是我没有推送任何代码,即使文件夹分支也没有没有我所期望的大师。
无论如何,也许这是我不知道如何使用git的错误,但是我该如何实现:我想在我的机器上开发Web应用程序,并且当某些功能准备就绪时,我想将其推送到本地Web服务器并使其启动并运行,而无需在服务器内部摆弄任何东西。我认为直接在/var/www/html
内建立一个git储存库是个好主意,但可能不是吗?
谢谢。