Skip to content

Instantly share code, notes, and snippets.

@heberop
Last active November 5, 2019 15:28
Show Gist options
  • Save heberop/396954e1ab6f3d5ba17790b048712d20 to your computer and use it in GitHub Desktop.
Save heberop/396954e1ab6f3d5ba17790b048712d20 to your computer and use it in GitHub Desktop.

Git Scripts

Fetch/Pull over all subdirectories

Bash

find . -type d -name .git -exec git --git-dir={} --work-tree=$PWD/{}/.. fetch -p \;

Powershell

Get-ChildItem -Recurse -Directory -Hidden  -Filter .git | ForEach-Object { & git --git-dir="$($_.FullName)" --work-tree="$(Split-Path $_.FullName -Parent)" fetch -p }

Delete all merged branches

git branch --merged | grep -v develop | xargs git branch -d
git branch --merged | %{$_.trim()} | ?{$_ -notmatch 'develop' -and $_ -notmatch 'master'} | %{ git branch -d $_ }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment