通过 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)

我怎么会变成这样:

流量

git checkout -b feature

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

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 克隆——您的回购:您可以推送到它。