我如何推送到远程的当前git分支,并立即反映更改? [英] How do I push to the current git branch on remote, and have changes reflected immediately?

查看:94
本文介绍了我如何推送到远程的当前git分支,并立即反映更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两台网络服务器,一台正在测试,一台正在运行。我们在测试服务器上进行开发,然后将测试服务器上的主分支上的更改推送到带有<$ c的活动服务器上$ c> git push 。但是,现在我必须登录到实时服务器并运行 git reset --hard ,以便将更改反映到实时代码中。



当我推送时,显示警告消息建议更改 receive.denyCurrentBranch 的设置以更改此推送的处理方式。然而,据我所知,我可以让它拒绝推送,接受它的警告,并需要一个 git reset ,或者接受它而不发出警告并且需要一个 git reset 。我可以让它接受不是需要重置吗?



谢谢!

解决方案

听起来你正在推进一个非裸回购(也就是说,有一个副本的回购文件在磁盘上签出)。你可以推入它,但是Git不会自动更新没有 git reset (或者 git checkout )。您可以使用post-receive钩子自动检查,但 - 有一个很好的方法可用这里


I've got a 2 web servers, one testing and one live. Both have their codebases managed with git.

I develop on the testing server, then push the changes from a master branch on the testing server to the live server with git push. However, at the moment I then have to log in to the live server and run git reset --hard for the changes to be reflected in the live code.

The warning message git displays when I push suggests changing the setting of receive.denyCurrentBranch to change how this push is handled. However, as I understand, I can either have it refuse the push, accept it with a warning and require a git reset, or accept it with no warning and require a git reset. Can I have it accept the push an not require the reset?

Thanks!

解决方案

It sounds like you're pushing into a non-bare repo (that is, one that has a copy of the repo's files checked out on-disk). You can push into it, but Git won't automatically update the working-copy files without a git reset (or git checkout). You could use a post-receive hook to do the checking out automatically, though -- there's a good how-to available here.

这篇关于我如何推送到远程的当前git分支,并立即反映更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆