我怎样才能阻止自己在Git的主分支? [英] How can I stop myself from committing to the master branch in git?
问题描述
我理想的工作流程是将变更提交到 开启 只会承诺主人。如果我很幸运,我会马上意识到这一点,但如果我不这样做,我可以在上游再推上10个变化。所以这最终在远程: 虽然它看起来应该是这样的: 如何删除人为因素(即我的愚蠢)并阻止自己从提交到主分支?我在Ubuntu上。 你可以很容易地写一个 pre-commit hook 检查你当前的分支,并根据分支名称拒绝提交。 My ideal workflow would be to commit changes onto On dev Writes some more code Whops, just committed to master. If I'm lucky I realize it right away, but if I don't I can push the branch upstream with another 10 changes on top. So this ends up in remote: While it should look like this: How can I remove the human factor (i.e. my stupidity) and stop myself from committing to the master branch? I'm on Ubuntu. You could pretty easily write a pre-commit hook to check your current branch and reject the commit based on the branch name. 这篇关于我怎样才能阻止自己在Git的主分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! dev
,并且只通过合并变更到master。git merge --no-ff dev $
dev:git add。
dev:git commit -m治愈癌症。
dev:git checkout master
master:git merge --no-ff dev
<
master:git commit -a -m做了些惊人的事情
主人--------合并---提交 - 提交--- ------------合并
Dev \ Commit / \ commit - commit /
主人--------合并 - ----------- Merge --------------------- Merge
Dev \ Commit / \ commit commit / \提交 - 提交 - 提交/
dev
and only merge changes to master via git merge --no-ff dev
, but occassionaly what happens is:dev: git add .
dev: git commit -m "Cured cancer."
dev: git checkout master
master: git merge --no-ff dev
master: git commit -a -m "Did something amazing"
Master -------- Merge --- commit - commit --------------- Merge
Dev \ Commit/ \ commit - commit /
Master -------- Merge ------------- Merge --------------------- Merge
Dev \ Commit/ \ commit commit / \ commit - commit - commit /