πŸ’‘Git

The Basics

Github flow
  • Model development and version control in article

Main CLI commands
  • git --version

  • git config

  • git config --global user.name = 'Klenin Maksim';

  • git config --global user.email = 'maksim_klenin_99@mail.ru';

  • git init

  • git add .

  • git commit -m "Commit"

  • git log

  • git status

  • git diff

  • git reset --hard HEAD

  • git show aa380fa8cc89695a3921114efc4dcde92ee09284

  • git checkout -b new-user-feature

  • git merge new-user-feature

  • git branch -d new-user-feature

  • git reset

  • git pull

Stash
  • git stash

  • git stash list

  • git stash apply

  • git stash apply stash@{0}

  • git stash drop

Aliases
  • git config --global alias.s status

  • git s

  • git config --global --unset alias.s

Logs

Beautiful log:

git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --branches"
git lg

Digging Deeper

Add hook pre-commit

Laravel pint:

  • touch .git/hooks/pre-commit

  • vim .git/hooks/pre-commit

  • chmod ug+x .git/hooks/*

Edit time in commit
  • git commit --amend --no-edit --date=now - Last commit to current time

Add multiple ssh keys for GitHub

Last updated