我设置了以下别名和功能,当我运行gca "My commit message"
时,我得到fatal: Paths with -a does not make sense
。知道如何解决这个问题吗?
alias gca='gca'
function gca() {
git commit -am "$1"
}
运行gca -x
会输出以下内容:
gca -x
error: unknown switch `x'
usage: git commit [<options>] [--] <pathspec>...
-q, --quiet suppress summary after successful commit
-v, --verbose show diff in commit message template
Commit message options
-F, --file <file> read message from file
--author <author> override author for commit
--date <date> override date for commit
-m, --message <message>
commit message
-c, --reedit-message <commit>
reuse and edit message from specified commit
-C, --reuse-message <commit>
reuse message from specified commit
--fixup <commit> use autosquash formatted message to fixup specified commit
--squash <commit> use autosquash formatted message to squash specified commit
--reset-author the commit is authored by me now (used with -C/-c/--amend)
-s, --signoff add Signed-off-by:
-t, --template <file>
use specified template file
-e, --edit force edit of commit
--cleanup <default> how to strip spaces and #comments from message
--status include status in commit message template
-S, --gpg-sign[=<key-id>]
GPG sign commit
Commit contents options
-a, --all commit all changed files
-i, --include add specified files to index for commit
--interactive interactively add files
-p, --patch interactively add changes
-o, --only commit only specified files
-n, --no-verify bypass pre-commit and commit-msg hooks
--dry-run show what would be committed
--short show status concisely
--branch show branch information
--porcelain machine-readable output
--long show status in long format (default)
-z, --null terminate entries with NUL
--amend amend previous commit
--no-post-rewrite bypass post-rewrite hook
-u, --untracked-files[=<mode>]
show untracked files, optional modes: all, normal, no. (Default: all)
答案 0 :(得分:1)
您有一个别名和一个具有相同名称的函数,PLUS别名定义了它自己。这没有意义。
删除别名定义。它应该可以工作,但如果你继续遇到问题,请加上
set -x
在函数的第一行(以及最后的set +x
)并再次运行。
或者,您可以删除该功能并按别名执行所有操作:
alias gcd='git commit -am'
答案 1 :(得分:0)
结果gca
是由oh-my-zsh
的git插件建立的别名。在source oh-my-zsh.sh
,~/.zshrc
和别名unalias gca
中的gca='git commit -am'
行之后,一切都按预期工作。所有未来读者都要注意 - 始终将您的自定义别名放在oh-my-zsh
之后。