From da6d3ccfd92491fc92f51b3ce7bcac6d7674e47f Mon Sep 17 00:00:00 2001 From: Alexandre Nedelec <15186176+TechWatching@users.noreply.github.com> Date: Wed, 10 Feb 2021 19:45:41 +0100 Subject: [PATCH] Add a command to clean up outdated git branches --- git/README.md | 14 ++++++++++++++ git/git_branchcleanup_.nu | 4 ++++ 2 files changed, 18 insertions(+) create mode 100644 git/README.md create mode 100644 git/git_branchcleanup_.nu diff --git a/git/README.md b/git/README.md new file mode 100644 index 0000000..36fc4d7 --- /dev/null +++ b/git/README.md @@ -0,0 +1,14 @@ +# Git Scripts + +### Definition + +These scripts should be used to demonstrate how combine the power of nushell with git commands. + +### Aliases +If you find some of these scripts useful you can add them as aliases in your git config file. + +For instance you can create a nushell script in your computer and define in your git config file an alias that call that script: +``` +[alias] + bcl = !nu \"D:\\Tools\\gitalias_bcl.nu\" +``` \ No newline at end of file diff --git a/git/git_branchcleanup_.nu b/git/git_branchcleanup_.nu new file mode 100644 index 0000000..b87d7ba --- /dev/null +++ b/git/git_branchcleanup_.nu @@ -0,0 +1,4 @@ +# Script that remove outdated local branches from a git repo +# More information on this article https://www.techwatching.dev/posts/cleaning-git-branches + +git branch -vl '*/*' | lines | split column " " BranchName Hash Status --collapse-empty | where Status == '[gone]' | each { git branch -D $it.BranchName } \ No newline at end of file