Git cheatsheet

Xianbo QIAN
1 min readMar 8, 2020

--

Undo the last commit

# If you don't want to keep the changes
git reset --hard HEAD^
# If you want to keep the changes
git reset --soft HEAD^

Save the credential so that you don’t need to type it each time.

# Store it permanently (only for trusted environment as it saves the credentials unencrypted.)
git config credential.helper store
# Store it temporarily in a cache with a timeout default to 900s (15mins)
git config --global credential.helper cache
# Change the timeout
git config --global credential.helper 'cache --timeout=300'
# Forget all caches before timeout
git credential-cache exit

--

--

No responses yet