そのため、私は時折、上キーを 1 回押す回数が多すぎたり少なすぎたりするという間違いを犯し、git commit -am "changed foo"
代わりに./foo_test
. メッセージが以前にコミットされたコミットのメッセージと一致するコミットを git 拒否することは可能ですか?
3295 次
2 に答える
6
完全に拒否するのではなく、元に戻してみてはどうでしょうか。
# Leaves all changes as 'changes to be committed', but
# uncommits the most recent commit
git reset --soft HEAD~
# Leaves all changes as changed working copy files (ie,
# unstages them as well)
git reset HEAD~
# Lets you edit the most recent commit message
git commit --amend
# Lets you do bulk surgery on your revision history, deleting
# or merging dozens of commits in one operation
git rebase -i <last good commit, eg origin/mainline>
本当にこれを完全に拒否したい場合は、確認してください.git/hooks/prepare-commit-msg
- そこにスクリプトを追加して ( 経由でgit cat-file commit HEAD
) 最新のコミット メッセージを取得し、渡されたコミット メッセージと比較することができます。それらが一致する場合はexit 1
、コミットを中止します。
于 2012-04-18T06:53:31.347 に答える
0
post-commit フック スクリプトを使用して確認します。
同じなら、git reset --mixed HEAD~1
于 2012-04-18T06:58:17.030 に答える