Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .bash_aliases
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,8 @@ alias gsync='set -x; git checkout main; gh repo sync; git pull; { set +x; } 2>/d

alias gw='git worktree'
__git_complete gw _git_worktree

alias gwa='~/scripts/git-worktree-add.sh'

alias gwr='~/scripts/git-worktree-remove.sh'
__git_complete gwr _git_checkout
15 changes: 15 additions & 0 deletions git-worktree-add.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ $# -ne 1 ]]; then
echo "Usage: $0 <branch-name>" >&2
exit 1
fi

name=$1

git worktree add --no-checkout -b "$name" "../$name"
cd "../$name"
git sparse-checkout init --cone
git sparse-checkout set .github/actions .github/shared .github/workflows
git checkout
12 changes: 12 additions & 0 deletions git-worktree-remove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
set -euo pipefail

if [[ $# -ne 1 ]]; then
echo "Usage: $0 <branch-name>" >&2
exit 1
fi

name=$1

git worktree remove "../$name"
git branch -D "$name"