Skip to content

Instantly share code, notes, and snippets.

@MonksterFX
Last active August 26, 2020 06:46
Show Gist options
  • Save MonksterFX/f92600e1a4a837ff77843e71830642f8 to your computer and use it in GitHub Desktop.
Save MonksterFX/f92600e1a4a837ff77843e71830642f8 to your computer and use it in GitHub Desktop.

clean up directory

getting an overview

show all branches remotes and local

git branch -a

show last commit for each branch

git branch -vv

if a branch has the gone flag, the remote was removed. Example:

[origin/<branch>: gone]

You can get all branches with state gone with:

git branch -vv | grep ': gone'

remove all branches localy, which are delete on remote

Check if branche are delete on remote

git fetch --prune

If you have local copies of this branches, search them with help of the gone flag and remove them with:

git branch -d or force deletion of unmerged branches with git branch -D

comment: git branch -d only deletes merged branches. This way it is relativly safe your not deleting any work.

unreferenced objects

show all unrefrenced objects which are effected when deleting by git prune: git prune --dry-run

docs

Discussion about git fetch prune

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment