Jump to content

Super bash by @Rongzhou

From Wikibase
 
Line 17: Line 17:


Merge pr and delete local git worktree + remote branches
Merge pr and delete local git worktree + remote branches
<syntaxhighlight lang="bash" copy>
b=$(gh pr view $pr --json headRefName -q .headRefName); w=$(git worktree list --porcelain | awk -v r="refs/heads/$b" '/^worktree /{p=substr($0,10)} /^branch / && $2==r {print p}'); [ -n "$w" ] && git worktree remove "$w"; gh pr merge $pr --merge --delete-branch
</syntaxhighlight>


<blockquote>
<blockquote>
First set `$pr` to the PR number.
First set `$pr` to the PR number.
</blockquote>
</blockquote>
<syntaxhighlight lang="bash" copy>
b=$(gh pr view $pr --json headRefName -q .headRefName); w=$(git worktree list --porcelain | awk -v r="refs/heads/$b" '/^worktree /{p=substr($0,10)} /^branch / && $2==r {print p}'); [ -n "$w" ] && git worktree remove "$w"; gh pr merge $pr --merge --delete-branch
</syntaxhighlight>


== File ops ==
== File ops ==

Latest revision as of 09:28, 15 October 2026

Remote:

git remote -v
git remote -h # for more options

Github CLI (gh)

Set remote:

gh repo set-default {target}

Merge pr and delete local git worktree + remote branches

First set `$pr` to the PR number.

b=$(gh pr view $pr --json headRefName -q .headRefName); w=$(git worktree list --porcelain | awk -v r="refs/heads/$b" '/^worktree /{p=substr($0,10)} /^branch / && $2==r {print p}'); [ -n "$w" ] && git worktree remove "$w"; gh pr merge $pr --merge --delete-branch

File ops

Enumerate non .gitignored files:

git ls-files -z '*.md' | xargs -0