Listing each branch and its last revision's date in Git

后端 未结 11 759
傲寒
傲寒 2020-11-29 15:07

I need to delete old and unmaintained branches from our remote repository. I\'m trying to find a way with which to list the remote branches by their last modified date, and

11条回答
  •  野性不改
    2020-11-29 15:35

    I did a simple alias, not sure if this is what exactly asked, but it is simple

    I did this as i wanted to list all the branches not just my local branches, which above commands do only

    alias git_brs="git fetch && git branch -av --format='\''%(authordate)%09%(authordate:relative)%09%(refname)'\'"

    You can pipe above to grep origin to get only origins

    This lists all the branches along with the last date modified, helps me decide which one i should pull for latest version

    This results in below type of display

    Wed Feb 4 23:21:56 2019 +0230   8 days ago      refs/heads/foo
    Tue Feb 3 12:18:04 2019 +0230   10 days ago     refs/heads/master
    Mon Feb 9 12:19:33 2019 +0230   4 days ago      refs/heads/bar
    Wed Feb 11 16:34:00 2019 +0230  2 days ago      refs/heads/xyz
    Tue Feb 3 12:18:04 2019 +0230   10 days ago     refs/remotes/origin/HEAD
    Mon Feb 9 12:19:33 2019 +0230   4 days ago      refs/remotes/origin/foo
    Tue Feb 3 12:18:04 2019 +0230   10 days ago     refs/remotes/origin/master
    Tue Feb 3 12:18:04 2019 +0230   10 days ago     refs/remotes/origin/bar
    Tue Feb 3 12:18:04 2019 +0230   10 days ago     refs/remotes/origin/xyz
    

    Try and let me know if it helped, happy gitting

提交回复
热议问题