Git
Git is a distributed version control system that tracks versions of files. It is often used to control source code by programmers collaboratively developing software.
Installation
sh
sudo apt install -y git
Configuration
sh
git config --global user.email "you@example.com"
sh
git config --global user.name "Your Name"
Actions
Erase a branch with another
Erase a branch with another
sh
git checkout branch_to_erase
git reset --hard branch_to_keep
Delete branch
sh
# local
git branch -d branch_to_delete
# on origin remote
git push origin --delete branch_to_delete
Commit changes on other branch
sh
git stash
git checkout other_branch
git stash pop
Unstage all files
sh
git reset
Add files and commit
sh
git commit -am
Pull to overwrite local files
Source : stackoverflow.com
sh
git fetch --all
Take master branch to overwrite local
sh
git reset --hard origin/master
With another branch
sh
git reset --hard origin/branch_name
Troubles
Conflicts with end of file
It's cause of Windows end of file (CRLF) conflict with Linux end of file (LF), just update global git core
sh
git config --global core.autocrlf false
And re-clone repository
“Pulling without specifying...”
“Pulling without specifying how to reconcile divergent branches is discouraged”
sh
git config --global pull.ff only
Change default editor
Example to change to vim editor
sh
git config --global core.editor "vim"
Cheatsheet
From elijahmanor.com