Push to remote server and Github
Summary: I want to edit files locally, then push to both Github and my web server.
I have the two remotes set up without issue, so right now I am sort of able to do this; however, I have to have branch A checked out locally, and branch B on the server. Then I have to SSH into the server and check out branch A (the one I want). I really don't even want or need a second branch, but many posts suggest that you can't or shouldn't push to a non-bare repository. There must be a better way. Even just using rsync would be easier than this (and I did it for a while).
Strangely, this never happens on Github. Almost all my repos only have one branch and I've never gotten this warning.
The warning message says that you can set receive.denyCurrentBranch
to ignore, but I don't know how safe/sane it is. I'm hoping someone will understand my vague description (which is due to my limited knowledge of git) and know the optimum solution.
It would be easier to set-up a post-receive hook on a bare repo on your web server.
That way, this hook can:
See "Git Post-Receive Hook for Website Staging" and the work in "Using Git to manage a web site":
$ mkdir /var/www/www.example.org
$ cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/www.example.org git checkout -f
$ chmod +x hooks/post-receive
(Note: fun fact, you can push to two different remote repos simultaneously)
链接地址: http://www.djcxy.com/p/49784.html上一篇: 移除主分支上的旧更改
下一篇: 推送到远程服务器和Github