From f8c09ca13ace7ad72007ecb57b779b8b973f8a9a Mon Sep 17 00:00:00 2001 From: Mohit Mayank Date: Sun, 12 Jan 2025 00:12:31 -0600 Subject: [PATCH 1/2] feat(git): add `gac` alias for staging and committing untracked files The new `gac` function adds a convenient alias for staging and committing an untracked file in a single command. Example Usage: - `gac file.txt "Add initial version"` This stages `myfile.txt` and commits it with the message "Add initial version." --- plugins/git/git.plugin.zsh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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' From 2889838f44c48a57f4da3771ed78aab844a3dc58 Mon Sep 17 00:00:00 2001 From: Mohit Mayank Date: Sun, 12 Jan 2025 00:14:50 -0600 Subject: [PATCH 2/2] Add `gac` function description to README --- plugins/git/README.md | 1 + 1 file changed, 1 insertion(+) 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**) |