Siner's Blog


깃 명령어 정리 - Git cheat sheet

잘 사용하지 않아서 까먹지만 필요하면 써야하는

2021/08/02


remove ignored files

$ git clean -dfX

git-clean - Remove untracked files from the working tree
-d for removing directories
-f remove forcefully
-n Don’t actually remove anything, just show what would be done.
-X Remove only files ignored by Git. This may be useful to rebuild everything from scratch, but keep manually created files.

remove untracked files

$ git clean -f # files only $ git clean -fd # include directories

ignore already committed files

$ git rm -r --cached . # remove cache $ git add . # add without ignored files

remove cached credential

$ git config --global --unset credential.helper

remove all fetched branches

This will prune any branches that no longer exist on the remote.

$ git fetch origin --prune

remove all local branches

$ git branch -d $(git branch)

remove all git stashes

$ git stash clear