Search code examples
gitterminalbitbucket

git command to display un-merged branches for particular user in master repo


git command to display un-merged branches for particular user in master repo

git branch -a --no-merged master

Used above command but unable to filter with specific user, as unmegred branches volume is 3k need to clean up them..


Solution

  • git branch -r --no-merged | xargs git show --no-patch --oneline --format='%cI %h %an %S' | grep "$(git config user.name)"
    

    -r: Remote Branches or `-a`: for all branches
    --no-merged:  Branches which are unmerged
    `|` pipe that command to `git show`
    xargs: passes each branch listed to `git show`
    --no-patch: suppress the diff output
    --oneline: pretty prints the output
    --format:
      - %cI: ISO8601 date format
      - %h: abbreviated commit hash
      - %an: Author name
      - %S: ref name
    `|` pipe that command to `grep`
    -- grep: grep the author configured at `git config user.name`