[英]How do I allow certain git commits to a branch but prevent them being merged into master?
Sometimes I branch out to write a feature but need an initial local commit which tweaks certain files in a way for me to work locally. 有时,我会扩展功能来编写功能,但是需要初始的本地提交,从而以某种方式对某些文件进行调整以使我可以在本地工作。 These changes are not to be merged back into master, so when the branch is ready I rebase it and remove the initial commit, which typically starts with the log message " DONT MERGE ". 这些更改不会被合并回master,因此当分支准备就绪时,我将其重新设置基础并删除初始提交,该提交通常以日志消息“ DONT MERGE ”开头。 But from time to time I still manage to merge that into master. 但是我仍然时不时地将其合并为大师。
Looking through the git hooks folder I see pre/post commit hooks, but nothing seems to look ideal for merges. 通过git hooks文件夹查看,我看到了提交前/提交后的钩子,但是似乎没有什么是合并的理想选择。 Is any of those hooks able to look at commits before them being merged too? 这些钩子中的任何一个也能够在合并之前查看提交吗? I want this to work locally on my machine, so I'm not looking for solutions which involve pushing to an external server like GitHub or Bitbucket. 我希望它可以在我的机器上本地运行,所以我不希望找到涉及推送到GitHub或Bitbucket等外部服务器的解决方案。
I'm going to suggest @Lasse's comment as an answer: 我将建议@Lasse的评论作为答案:
It sounds like you want to have different configurations for local and production development, in that case you should look into having a config file that is ignored by git that you change locally. 听起来您想为本地和生产开发使用不同的配置,在这种情况下,您应该考虑使用一个在本地更改的git忽略的配置文件。 You could commit different example config files that are not actually used so that you don't have to remember all the details. 您可以提交未实际使用的其他示例配置文件,从而不必记住所有详细信息。 For example: 例如:
config.txt
configProductionExample.txt
configLocalDevExample.txt
Or you could commit multiple startup scripts, one for each environment you want to work in. For example: 或者,您可以提交多个启动脚本,每个启动脚本用于您要使用的每种环境。例如:
startProduction.sh
startLocalDev.sh
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.