删除所有没有最近提交的远程分支
Remove all remote branches without recent commits
我在 git 基于流的环境中工作。
我们(连同团队)决定在一段时间内不删除远程分支。我怎样才能从我的遥控器中删除最近 X 天没有提交的所有功能分支。我想这可能是一些 oneliner?
根据:How can I get a list of git branches, ordered by most recent commit? 我可以得到按最后提交日期排序的分支。
这里:How to clone all remote branches in Git?我可以克隆所有远程分支。
我可以避免拉取所有远程分支进行此类清理吗?
您可以避免拉取所有远程分支。
这将为您提供所有远程功能分支,按提交日期排序,并将显示最后一次提交的日期、提交者和分支的简称。
git for-each-ref --sort=-committerdate refs/remotes/origin/feature --format='%(committerdate:short) %(authorname) %(refname:short)'
或者您可以显示相对于今天的提交日期
git for-each-ref --sort=-committerdate refs/remotes/origin/feature --format='%(committerdate:relative) %(authorname) %(refname:short)'
您所要做的就是select您要删除哪些分支并执行此操作。
git push origin :feature/newfeature
也许可以创建一个 oneliner,但我认为用您喜欢的任何语言编写一个小脚本会更容易。
我在 git 基于流的环境中工作。 我们(连同团队)决定在一段时间内不删除远程分支。我怎样才能从我的遥控器中删除最近 X 天没有提交的所有功能分支。我想这可能是一些 oneliner?
根据:How can I get a list of git branches, ordered by most recent commit? 我可以得到按最后提交日期排序的分支。
这里:How to clone all remote branches in Git?我可以克隆所有远程分支。
我可以避免拉取所有远程分支进行此类清理吗?
您可以避免拉取所有远程分支。
这将为您提供所有远程功能分支,按提交日期排序,并将显示最后一次提交的日期、提交者和分支的简称。
git for-each-ref --sort=-committerdate refs/remotes/origin/feature --format='%(committerdate:short) %(authorname) %(refname:short)'
或者您可以显示相对于今天的提交日期
git for-each-ref --sort=-committerdate refs/remotes/origin/feature --format='%(committerdate:relative) %(authorname) %(refname:short)'
您所要做的就是select您要删除哪些分支并执行此操作。
git push origin :feature/newfeature
也许可以创建一个 oneliner,但我认为用您喜欢的任何语言编写一个小脚本会更容易。