Giter VIP home page Giter VIP logo

git-prunning's Introduction

git-prunning

Delete old git branches with ease.

To delete all local branches which has been merged:

git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d

Explanation:

  • git branch –merged : first, you are simply listing all the branches currently merged with your current checked out branch;
  • egrep -v "(^*|main|dev)" : you are using the invert matching feature of grep in order to exclude any branches that may be called “main” or “dev”.
  • xargs git branch -d : you are deleting every single branch listed before.

To delete all unused remote branches which has not been merged:

git branch -r --merged | egrep -v "(^\*|master|dev)" | xargs -n 1 git push --delete origin

Same as before, but the -r is for remote.

To delete remote references:

git remote prune origin

The git remote prune origin command is used to remove local references to remote branches that have been deleted on the remote repository (in this case, "origin").

When you fetch updates from a remote repository, your local repository keeps references to remote branches. If a branch is deleted on the remote repository, your local repository might still have references to it. Running git remote prune origin will remove these stale references, keeping your local repository in sync with the remote one.

Do it automatically with (this happens on every fetch):

git config --global fetch.prune true

git-prunning's People

Contributors

eznix86 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.