Useful git commands

remove all unversioned and not ignored files:

before to see what will be deleted

$ git clean -fn

perform deletion

$ git clean -f

remove files from staged state:

$ git reset HEAD [files..]

take back uncommitted and unstaged files

$ git checkout $FILE

for all files

$ git checkout .

„re-fetch“ branch from origin (useful if it was force-pushed)

$ git reset --hard origin/$BRANCH

Add change to last commit without changing the commit message

$ git commit --amend --no-edit

Just change the last commit message

$ git commit --amend -m "New commit message"

remove branches which don’t exist in origin

$ git remote prune origin

configure a new alias

$ git config --global alias.xx bla