diff --git a/plugins/git/README.md b/plugins/git/README.md index bcadc4713..75fb37cc6 100644 --- a/plugins/git/README.md +++ b/plugins/git/README.md @@ -265,6 +265,7 @@ receive further support. | `git_develop_branch` | Returns the name of the “development” branch: `dev`, `devel`, `development` if they exist, `develop` otherwise. | | `git_main_branch` | Returns the name of the main branch: `main` if it exists, `master` otherwise. | | `grename ` | Renames branch `` to ``, including on the origin remote. | +| `gac` | Stages and commits an untracked file. | | `gbda` | Deletes all merged branches | | `gbds` | Deletes all squash-merged branches (**Note: performance degrades with number of branches**) | diff --git a/plugins/git/git.plugin.zsh b/plugins/git/git.plugin.zsh index f34c0726b..ef489c88a 100644 --- a/plugins/git/git.plugin.zsh +++ b/plugins/git/git.plugin.zsh @@ -115,6 +115,22 @@ alias gamscp='git am --show-current-patch' alias gams='git am --skip' alias gap='git apply' alias gapt='git apply --3way' + +# Adds and commits an untracked file. +function gac() { + if [ $# -lt 2 ]; then + echo "Usage: gac " + return 1 + fi + + local file="$1" + shift + local message="$@" + + git add "$file" + git commit -m "$message" +} + alias gbs='git bisect' alias gbsb='git bisect bad' alias gbsg='git bisect good'