我有一个Bitnami WordPress虚拟机,我正在尝试使用https配置。它的Apache配置目录如下所示,我可以使用它。
我宁愿在本地编辑文件(使用Sublime Text的macos)。
我经常开始使用Git跟踪现有配置目录,但效果非常好。问题是我无法弄清楚如何在遥控器上获得相同的工作流程。
bitnami@debian:/opt/bitnami/apache2$ tree conf -d
conf
├── bitnami
├── extra
└── original
└── extra
出于某种原因,我无法让git daemon
令人满意地工作,所以我最终使用git而不是ssh。这很好,因为我避免在VM上保护git。
然而,我不能完全按照我的意愿去工作。 (在这两种情况下,我事先将实际的conf复制到〜/ temp 。)
git init工作,我看到我的所有文件+ git东西:
bitnami@debian:~/temp$ cp -r /opt/bitnami/apache2/conf/ .
bitnami@debian:~/temp$ cd conf
bitnami@debian:~/temp/conf$ git init --bare
Initialized empty Git repository in /home/bitnami/temp/conf/
bitnami@debian:~/temp/conf$ ls -ltr | tail -10
-rw-r--r-- 1 bitnami bitnami 891 Sep 22 04:07 ca.key
drwxr-xr-x 2 bitnami bitnami 4096 Sep 22 04:07 bitnami
drwxr-xr-x 4 bitnami bitnami 4096 Sep 22 04:10 refs
drwxr-xr-x 4 bitnami bitnami 4096 Sep 22 04:10 objects
drwxr-xr-x 2 bitnami bitnami 4096 Sep 22 04:10 info
drwxr-xr-x 2 bitnami bitnami 4096 Sep 22 04:10 hooks
-rw-r--r-- 1 bitnami bitnami 23 Sep 22 04:10 HEAD
-rw-r--r-- 1 bitnami bitnami 73 Sep 22 04:10 description
-rwxr--r-- 1 bitnami bitnami 66 Sep 22 04:10 config
drwxr-xr-x 2 bitnami bitnami 4096 Sep 22 04:10 branches
jluc@temp$ git clone ssh://bitnami@$IP_WP2/home/bitnami/temp/conf
Cloning into 'conf'...
bitnami@192.168.1.147's password:
warning: You appear to have cloned an empty repository.
jluc@temp$ cd conf
jluc@conf$ ls -ltr
jluc@conf$
果然,mac上没有文件。
除非它不起作用。
bitnami@debian:~/temp/conf$ git add .
fatal: This operation must be run in a work tree
bitnami@debian:~/temp/conf$ cd ..
bitnami@debian:~/temp$ rm -rf conf/
bitnami@debian:~/temp$ cp -r /opt/bitnami/apache2/conf/ .
bitnami@debian:~/temp$ cd conf
bitnami@debian:~/temp/conf$ git init .
Initialized empty Git repository in /home/bitnami/temp/conf/.git/
然后添加所有内容:
bitnami@debian:~/temp/conf$ git add .
bitnami@debian:~/temp/conf$ git status
On branch master
Initial commit
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: bitnami/bitnami-apps-prefix.conf
new file: bitnami/bitnami-apps-vhosts.conf
new file: bitnami/bitnami.conf
new file: bitnami/httpd-2xlarge.conf
....
并提交
git commit -am "just init"
[master (root-commit) a13fb20] just init
50 files changed, 7847 insertions(+)
create mode 100644 bitnami/bitnami-apps-prefix.conf
create mode 100644 bitnami/bitnami-apps-vhos
...
克隆
jluc@temp$ git clone ssh://bitnami@$IP_WP2/home/bitnami/temp/conf
Cloning into 'conf'...
bitnami@192.168.1.147's password:
Permission denied, please try again.
bitnami@192.168.1.147's password:
remote: Counting objects: 45, done.
remote: Compressing objects: 100% (45/45), done.
remote: Total 45 (delta 8), reused 0 (delta 0)
Receiving objects: 100% (45/45), 84.87 KiB | 0 bytes/s, done.
Resolving deltas: 100% (8/8), done.
创建一个虚拟文件并提交它:
jluc@temp$ cd conf
jluc@conf$ touch test.txt
jluc@conf$ git add test.txt
jluc@conf$ git commit -am "just a test.txt file to test"
[master 3789f21] just a test.txt file to test
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test.txt
当我按下它时出错:
jluc@conf$ git push origin master
bitnami@192.168.1.147's password:
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 282 bytes | 0 bytes/s, done.
Total 3 (delta 1), 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
..... more stuff...
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To ssh://192.168.1.147/home/bitnami/temp/conf
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'ssh://bitnami@192.168.1.147/home/bitnami/temp/conf'
我查看了一些 git init --bare 帖子,但还没找到与我的用例匹配的帖子。
git版本之间存在许多相关更改并且答案有时会发生冲突,这无济于事。
根据https://stackoverflow.com/questions/11117823/git-push-error-refusing-to-update-checked-out-branch git config --bool core.bare true
会有帮助吗?我应该什么时候运行呢? mac克隆之后?我试过这样做,我的git push origin master没有抱怨,但我也没有在VM上看到我的新test.txt文件。
git-how-to-start-tracking-an-existing-project似乎相关,但接受的答案的链接会返回404错误。
答案 0 :(得分:1)
您案件的通常工作流程是:
在推送之前,使用如下行:
在您的裸仓库中添加一个接收后挂钩git --git-dir=/path/to/project_root/.git --work-tree=/path/to/public_html/app checkout -f
这样,每次推送时,文件都会在原始的Apache文件夹中签出 (根据你的情况调整路径)