- List of untracked files
git clean -n
- Delete untracked files
git clean -f
- To remove directories
git clean -f -d or git clean -fd
- To remove ignored files
git clean -f -X or git clean -fX
- To remove ignored and non-ignored files
git clean -f -x or git clean -fx
- Delete branch locally
git branch -d localBranchName
The -d option will delete the branch only if it has already been pushed and merged with the remote branch. Use -D instead if you want to force the branch to be deleted, even if it hasn't been pushed or merged yet.
- Delete branch remotely
git push origin --delete remoteBranchName
git commit --amend --no-edit
git push -f
git rm -r --cached .
git add .
git commit -am "Remove ignored files"