not-an-aardvark/git-delete-squashed
소개
main 브랜치에 스쿼시 병합된 브랜치를 삭제합니다.
개발 도구측정된 스타 증가
- in 24h
- 0
- in 7 days
- 0
- in 15 days
- 0
- in 1 month
- 기록 수집 중
서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.
README.md
Originalgit-delete-squashed
This is a tool that deletes all of your git branches that have been "squash-merged" into master.
This is useful if you work on a project that squashes branches into master. After your branch is squashed and merged, you can use this tool to clean up the local branch.
Usage
sh
To run as a shellscript, simply copy the following command (setting up an alias is recommended). There's no need to clone the repo.
# Change $TARGET_BRANCH to your targeted branch, e.g. change from `master` to `main` to delete branches squashed into `main`.
TARGET_BRANCH=master && git checkout -q $TARGET_BRANCH && git for-each-ref refs/heads/ "--format=%(refname:short)" | while read branch; do mergeBase=$(git merge-base $TARGET_BRANCH $branch) && [[ $(git cherry $TARGET_BRANCH $(git commit-tree $(git rev-parse $branch\^{tree}) -p $mergeBase -m _)) == "-"* ]] && git branch -D $branch; done
# OR you can put this function in a global git alias and call it like this
# `git delete-squashed` OR `git delete-squashed main`
git config --global alias.delete-squashed '!f() { local targetBranch=${1:-master} && git checkout -q $targetBranch && git branch --merged | grep -v "\*" | xargs -n 1 git branch -d && git for-each-ref refs/heads/ "--format=%(refname:short)" | while read branch; do mergeBase=$(git merge-base $targetBranch $branch) && [[ $(git cherry $targetBranch $(git commit-tree $(git rev-parse $branch^{tree}) -p $mergeBase -m _)) == "-"* ]] && git branch -D $branch; done; }; f'
Node.js
You can also install the tool as a Node.js package from NPM. (The package code is in this repo.)
Additionally, you can specify an alternate branch to check for squashed merges, as well. This is useful for different names of trunk branches like main or develop.
$ npm install --global git-delete-squashed
$ git-delete-squashed
$ # Specify a different branch name like so
$ git-delete-squashed main
Details
To determine if a branch is squash-merged, git-delete-squashed creates a temporary dangling squashed commit with git commit-tree. Then it uses git cherry to check if the squashed commit has already been applied to master. If so, it deletes the branch.
관련 프로젝트 살펴보기
불러오는 중…