Git Cheatsheet

Git Cheatsheet

Git is awesome.

GPG

Export GPG Key to Bash

echo 'export GPG_TTY=$(tty)' >> ~/.bashrc

Prepare Repository

Initialize Repository

git init

Clone Repository

git clone <url> <dir>

Configuration

Enable Signing

git config --global commit.gpgsign true

Use gpg2

git config --global gpg.program gpg2

List GPG Keys

gpg --list-secret-keys --keyid-format LONG


/home/ravindra/.gnupg/pubring.kbx
---------------------------------
sec   rsa4096/CB0F259B96C06BD7 2018-07-09 [SC]
uid                 [ultimate] Ravindra Sisodia <rscipher001@gmail.com>
ssb   rsa4096/80FAD53E2BC58FD2 2018-07-09 [E]

Copy CB0F259B96C06BD7 from output

Change Git Config

git config --global user.signingkey CB0F259B96C06BD7

Force push

git push --force

Force push (to newly added remote)

git push -u origin master --force

Undo Everything after last commit

git reset HEAD --hard

Delete all untracked files

git clean -f

Delete all untracked files and directories

git clean -fd

Original:  Updated: