Jump to content

Super bash by @Rongzhou

From Wikibase
Created page with "== Git and related == === Github CLI (<code>gh</code>) === Merge pr and delete local git worktree + remote branches <syntaxhighlight lang="bash" copy> b=$(gh pr view 118 --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 118 --merge --delete-branch </syntaxhighlight>"
 
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
== Git and related ==
== Git and related ==
Remote:
<syntaxhighlight lang="bash" copy>
git remote -v
git remote -h # for more options
</syntaxhighlight>


=== Github CLI (<code>gh</code>) ===
=== Github CLI (<code>gh</code>) ===
Set remote:
<syntaxhighlight lang="bash" copy>
gh repo set-default {target}
</syntaxhighlight>


Merge pr and delete local git worktree + remote branches
Merge pr and delete local git worktree + remote branches
<blockquote>
First set `$pr` to the PR number.
</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 ==
Enumerate non <code>.gitignore</code>d files:
<syntaxhighlight lang="bash" copy>
<syntaxhighlight lang="bash" copy>
b=$(gh pr view 118 --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 118 --merge --delete-branch
git ls-files -z '*.md' | xargs -0
</syntaxhighlight>
</syntaxhighlight>

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