Git

Basics

  • git setup

git config --global user.name "NafiAsib"
git config --global user.email "[email protected]"
git config --global color.ui true # enable colored output in terminal
git config --global core.editor nvim

# ↓ OLD
# git config --global credential.helper cache --timeout=3600 # cache password for 3600 second
# git config --global credential.helper cache
# git config --global --unset credential.helper
# git config --global core.editor code      # only in windows
# git config --global core.autocrlf true    # only in windows
  • SSH key

cd ~/.ssh
ssh-keygen -t rsa -C "[email protected]" -f "id_rsa_github"
# -t rsa β‡’ Specifies the type of key to create. In this case, it's rsa
# -C β‡’ comment
# -f β‡’ filename

Now copy the content of id_rsa_github.pub and set as SSH key in GitHub.

You can confirm that SSH is okay by typing ssh -T [email protected]

If you see following message, you're done!

  • git directory initialization

  • remove a file

reset last commit

git merge conflicts

To solve merge conflict between two branch, first pull the other branch in your working branch. Then merge all conflict and push. It's better to squash your commits to make the commit tree clean.

git squash last X commits

Reset rebase

git ammend

using interactive rebase

Errors & fix

Solve

restart terminal

Resources

Last updated