通过 Git 以 Github 私有仓库为主的部署完全控制
Complete control via Git over deployment with Github private repo as main
我正在学习和调整集成 Git 的工作流程。我的愿望是能够将我的开发分支从我的本地终端推送到我的测试服务器。一旦我分支,我当前的设置就会给我一个错误。我感觉这不是一个错误,而是 Git 完成了它的工作,再加上我没有完全理解它。 您能解释为什么会发生这种情况以及如何避免这种情况吗?
Git“错误”
! [remote rejected] feature -> feature (branch is currently checked out)
error: failed to push some refs to (I hide the ssh server address)
我怎么会变成这样:
- 在 github
上创建存储库
- 包括通过 cpanel 从我的服务器生成的部署密钥
- Git 在本地机器上克隆
- Git 通过 SSH 在服务器上克隆
- 将远程服务器添加到 repo 作为测试
流量
在本地调整 master,将其推送到 github,服务器一切正常。但我的理解是 Git 的强大功能是为 'feature' 创建一个分支 > 测试它 > 将它合并到 master。
我在本地机器上创建了一个名为 feature 的分支
git checkout -b feature
- 对 repo 进行一些更改并将其推送到 origin 并进行测试
git add .
git commit -m 'added index.html'
git push origin feature (for backup/sync purposes)
git push test feature (to be able so see my code working on the test server
我必须 'checkout' 新分支才能显示服务器上的文件,所以我 SSH 到我的服务器并检出新分支:
git checkout feature
My thinking is, that from this point on, I can work on feature branch locally > commit adjustments and with a simple push command git push test feature
I can test the code on my test server.
断流
但是现在我的流量坏了。在我检查服务器上的功能分支后,我无法将调整后的分支推送到我的远程测试。 Git returns 上面显示的消息。
Git clone on server via SSH
您仍然需要通过 SSH 会话在该服务器上添加:
cd /path/to/cloned/repo
git config --local receive.denyCurrentBranch updateInstead
意思是,使用 Git 2.4 或更高版本 using a push-to-deploy,以允许 git 推送直接更新 checked out工作树。
通常,您宁愿推送到裸存储库:请参阅“", and use a .
即:一个名为 post-receive
的可执行 (chmod 775
) 文件,位于“myrepo.git/hooks
”文件夹中,详见 in the discussion.
myrepo.git
是服务器上的 git 克隆——您的回购:您可以推送到它。
我正在学习和调整集成 Git 的工作流程。我的愿望是能够将我的开发分支从我的本地终端推送到我的测试服务器。一旦我分支,我当前的设置就会给我一个错误。我感觉这不是一个错误,而是 Git 完成了它的工作,再加上我没有完全理解它。 您能解释为什么会发生这种情况以及如何避免这种情况吗?
Git“错误”
! [remote rejected] feature -> feature (branch is currently checked out)
error: failed to push some refs to (I hide the ssh server address)
我怎么会变成这样:
- 在 github 上创建存储库
- 包括通过 cpanel 从我的服务器生成的部署密钥
- Git 在本地机器上克隆
- Git 通过 SSH 在服务器上克隆
- 将远程服务器添加到 repo 作为测试
流量
在本地调整 master,将其推送到 github,服务器一切正常。但我的理解是 Git 的强大功能是为 'feature' 创建一个分支 > 测试它 > 将它合并到 master。
我在本地机器上创建了一个名为 feature 的分支
git checkout -b feature
- 对 repo 进行一些更改并将其推送到 origin 并进行测试
git add .
git commit -m 'added index.html'
git push origin feature (for backup/sync purposes)
git push test feature (to be able so see my code working on the test server
我必须 'checkout' 新分支才能显示服务器上的文件,所以我 SSH 到我的服务器并检出新分支:
git checkout feature
My thinking is, that from this point on, I can work on feature branch locally > commit adjustments and with a simple push command
git push test feature
I can test the code on my test server.
断流
但是现在我的流量坏了。在我检查服务器上的功能分支后,我无法将调整后的分支推送到我的远程测试。 Git returns 上面显示的消息。
Git clone on server via SSH
您仍然需要通过 SSH 会话在该服务器上添加:
cd /path/to/cloned/repo
git config --local receive.denyCurrentBranch updateInstead
意思是,使用 Git 2.4 或更高版本 using a push-to-deploy,以允许 git 推送直接更新 checked out工作树。
通常,您宁愿推送到裸存储库:请参阅“
即:一个名为 post-receive
的可执行 (chmod 775
) 文件,位于“myrepo.git/hooks
”文件夹中,详见 in the discussion.
myrepo.git
是服务器上的 git 克隆——您的回购:您可以推送到它。