git 将更改推送到远程仓库而不提交

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4582578/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 09:43:56  来源:igfitidea点击:

Push changes to remote repo without commit

git

提问by ryudice

Is it possible to push changes to a remote repository without commiting to the master branch? I use the remote repo just for deploying.

是否可以将更改推送到远程存储库而不提交到主分支?我使用远程仓库仅用于部署。

采纳答案by fresskoma

No, there is no way to do that, as it would completely oppose the whole "git strategy", I guess. I don't know about your deployment system, but I guess a good way to do what you are trying to is to work on different branches (that is, on for development and one which gets deployed when pushed to), and merging the changes you want to be deployed from your development-branch into your live branch.

不,没有办法做到这一点,因为它会完全反对整个“git 策略”,我猜。我不知道你的部署系统,但我想做你想做的事情的一个好方法是在不同的分支上工作(即,用于开发并且在推送到时被部署),并合并更改您希望从开发分支部署到实时分支。

回答by Andrew Homeyer

You can create an empty commit and push that: git commit --allow-empty

您可以创建一个空提交并推送: git commit --allow-empty

回答by Ryan Bigg

No, you must make a commit before you can push. What is being pushed is the commit (or commits).

不,您必须先提交才能推送。推送的是提交(或提交)。

回答by sabalaba

If you want to push a specific commit:

如果要推送特定提交:

git push <remotename> <commit SHA>:<remotebranchname>

回答by Aftab Naveed

If you have deployment code in post-receive hook then you only need to execute that from shell (sh post-receive) that actually worked for me a few times.

如果你在 post-receive 钩子中有部署代码,那么你只需要从 shell (sh post-receive) 执行它,它实际上对我有用几次。