Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7845691
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:19:26+00:00 2026-06-02T17:19:26+00:00

I found the below script that lists the branches by date. How do I

  • 0

I found the below script that lists the branches by date. How do I filter this to exclude newer branches and feed the results into the Git delete command?

for k in $(git branch | sed /\*/d); do 
  echo "$(git log -1 --pretty=format:"%ct" $k) $k"
done | sort -r | awk '{print $2}'
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:19:29+00:00Added an answer on June 2, 2026 at 5:19 pm

    How about using --since and --before?

    For example, this will delete all branches that have not received any commits for a week:

    for k in $(git branch | sed /\*/d); do 
      if [ -z "$(git log -1 --since='1 week ago' -s $k)" ]; then
        git branch -D $k
      fi
    done
    

    If you want to delete all branches that are more than a week old, use --before:

    for k in $(git branch | sed /\*/d); do 
      if [ -z "$(git log -1 --before='1 week ago' -s $k)" ]; then
        git branch -D $k
      fi
    done
    

    Be warned though that this will also delete branches that where not merged into master or whatever the checked out branch is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for some help. I have found this script that sort of
I am trying to upload image on server, below is script that I found
I was looking at the pagination script (posted below) and found it to be
I wanted to be able to Pause/ Resume my NSTimer and found this below
Below is some html I found in this jquery tooltip tutorial, the contents inside
I found this orientation test code below looking for JQTouch reference material. This works
When initializing a new Date object in JavaScript using the below call, I found
Does anybody know how to modify the below script so that, in addition to
From the tutorial ScriptJSONOptions of FirebugLite page, I found the below: Script JSON options
I finally managed to get the PHP script below to work...but then I found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.