Reputation: 4376
I have the below alias and function set up, and when I run gca "My commit message"
I get fatal: Paths with -a does not make sense
. Any idea how I can fix this?
alias gca='gca'
function gca() {
git commit -am "$1"
}
Running gca -x
outputs the following:
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)
Upvotes: 0
Views: 666
Reputation: 4376
Turns out gca
was an alias established by the git plugin for oh-my-zsh
. After the source oh-my-zsh.sh
line in my ~/.zshrc
, I unalias gca
, and alias gca='git commit -am'
and everything works as expected. Note to all future readers - always put your custom aliases after things such as oh-my-zsh
.
Upvotes: 0
Reputation: 22291
You have an alias and a function with the same name, PLUS the alias defines itself. This doesn't make sense.
Remove the alias definition. It should then work, but if you continue to encounter problems, put a
set -x
in the first line of your function (and a set +x
at the end) and run it again.
Alternatively, you can drop the function and do everything by alias:
alias gcd='git commit -am'
Upvotes: 1