Konfiguracja

git config --global user.name "username"
git config --global user.email "user@email.tld"

Ignorowanie zapomnianych plików

git update-index --assume-unchanged <file>
git update-index --skip-worktree 

Undo Local Unstaged Changes

git restore <file>

Undo Local Staged Changes

git restore --staged <file>

Undo Local Committed Changes

„Cofnij” ostatni commit (bez ruszania plików)

git reset HEAD^
git reset --soft HEAD~
git reset --hard HEAD~

Usuń N ostatnich commitów

Użyj zakresu HEAD~N, jako argumentu dla git reset.

git reset --hard HEAD~N

Undo Public Committed Changes

git log --oneline
git revert cc3bbf7 --no-edit

Odzyskiwanie

Odzyskaj wersję pliku z konkretnego commitu:

git checkout <commit> <file>

albo

git restore <file> --source <commit>

fsck

git fsck --lost-found
git fsck --unreachable

Delete orphan commits

git reflog expire --expire=now --all
git gc --prune=now
# git gc --prune=all --aggressive

Log

git log --all --decorate --oneline --graph

Pokaż każdy commit, który zmienił <file>

git log <file>

Credentials

apt-get install gcc make
apt-get install libgnome-keyring-dev
cd /usr/share/doc/git/contrib/credential/gnome-keyring
make
git config --global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring

Gałęzie

git branch <branchname>
git checkout <branchname>

albo

git checkout -b <branchname>

More information

Refs