3 回答

TA貢獻1836條經驗 獲得超3個贊
我在編寫Java代碼時遇到了類似的問題。我的解決方案是標記不想提交的代碼,然后添加一個預提交的鉤子來尋找我的標記:
#!/bin/bash
#
# This hook will look for code comments marked '//no-commit'
# - case-insensitive
# - dash is optional
# - there may be a space after the //
#
noCommitCount=$(git diff --no-ext-diff --cached | egrep -i --count "(@No|\/\/\s?no[ -]?)commit")
if [ "$noCommitCount" -ne "0" ]; then
echo "WARNING: You are attempting to commit changes which include a 'no-commit'."
echo "Please check the following files:"
git diff --no-ext-diff --cached --name-only -i -G"(@no|\/\/s?no-?)commit" | sed 's/^/ - /'
echo
echo "You can ignore this warning by running the commit command with '--no-verify'"
exit 1
fi

TA貢獻1794條經驗 獲得超8個贊
這是有趣的。但這基本上就像問題線不存在一樣。對于像只是簡單地更改一行更改之類的操作,它是行不通的。因此,例如,您不能在函數調用中更改變量的值。例如,您不必確保將其更改flags = foo | bar
為flags = foo | bar | debug_thingy
,而是必須添加一個像flags |= debug_thingy
after之后的全新行。
- 3 回答
- 0 關注
- 710 瀏覽
添加回答
舉報