add git alias for worktree workflows
This commit is contained in:
parent
c892680974
commit
6faed4df92
2
.local/bin/git-cln
Executable file
2
.local/bin/git-cln
Executable file
@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
sh ~/.local/bin/git-worktree-setup.sh "$@"
|
||||
21
.local/bin/git-worktree-setup.sh
Normal file
21
.local/bin/git-worktree-setup.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
url=$1
|
||||
basename=${url##*/}
|
||||
name=${2:-${basename%.*}}
|
||||
|
||||
mkdir -p "$name"
|
||||
cd "$name"
|
||||
|
||||
git clone --bare "$url" .bare
|
||||
echo "gitdir: ./.bare" > .git
|
||||
|
||||
git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
|
||||
git fetch origin
|
||||
|
||||
default_branch=$(git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
|
||||
git worktree add "$default_branch"
|
||||
|
||||
osascript -e "tell application \"Terminal\" to do script \"cd '$PWD/$default_branch' && clear\" in front window"
|
||||
Loading…
x
Reference in New Issue
Block a user