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 关注
- 665 浏览
添加回答
举报