Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

git delete all remote branches except master

git branch -r | grep 'origin' | grep -v 'master$' | grep -v HEAD | cut -d/ -f2- | while read line; do git push origin :heads/$line; done;
Comment

remove all branches deleted on remote

# Shorthand for deleting localy all branches already deleted on remote
# set this alias in git.config
git config --global alias.gone "! git fetch -p && git for-each-ref --format '%(refname:short) %(upstream:track)' | awk '$2 == "[gone]" {print $1}' | xargs -r git branch -D"
# then run
git gone
Comment

git delete all remote branch except master

git branch -r | grep 'origin' | grep -v 'master$' | grep -v 'develop$' | grep -v HEAD | cut -d/ -f2- | while read line; do git push origin :heads/$line; done;
Comment

Git - Delete all local branches where the remote branch was deleted

# Delete all remote tracking Git branches where the upstream branch has been deleted
alias git_prune="git fetch --prune && git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d"
Comment

remove deleted remote branches locally

git fetch -p && for branch in $(git for-each-ref --format '%(refname) %(upstream:track)' refs/heads | awk '$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'); do git branch -D $branch; done
Comment

PREVIOUS NEXT
Code Example
Shell :: install latest node js ubuntu 
Shell :: conda install pandas 
Shell :: install node_modules 
Shell :: add more changes to same commit 
Shell :: git commit single file 
Shell :: scp linux file to windows from windows. 
Shell :: how to create new repository in github 
Shell :: class sorting in tailwindcss 
Shell :: linux x11 dev 
Shell :: push to github 
Shell :: linux ping a port 
Shell :: haskell change version 
Shell :: find text in linux file 
Shell :: tree command 
Shell :: powershell replace and rename file name 
Shell :: how to check what module pip has already install 
Shell :: lumen with specific version 
Shell :: install cassandra ubuntu 
Shell :: undo git commit and keep changes 
Shell :: shutdown command rhel 7 
Shell :: generate github access token 
Shell :: gatsby transformer remark 
Shell :: add user to dialout group 
Shell :: how to upgrade packages in ubuntu 20.04 
Shell :: create and switch to a branch 
Shell :: skip husky 
Shell :: linux command to go to the previous directory 
Shell :: how to install socket.io to node js 
Shell :: uninstall utorrent buntu 
Shell :: brew upgrade 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =