Here are the terminal commands you can use instead of Gitkraken . This note is for situations where GitKraken isn't available. For a full list of git commands, refer to this note: Git!

Clone a repo

git clone <repo-link>
# or using gh

Check status (what are in stage or unstage)

git status

Show list of commits

# local, current branch
git log --graph --decorate --oneline
# press "q" to quit

# remote branch b1 (local may have different commits)
git fetch origin
git log origin/b1 --graph --decorate --oneline

Working with branches

# Create a new branch from a commit
git checkout -b <new_branch_name> <commit_hash>

# Create a new branch based on another branch
git checkout -b <new_branch_name> <existing_branch_name>

# push to remote
git push -u origin <new_branch_name>

# force to push
git push origin <branch-name> -f

# Rename currently local branch
git branch -m <new_branch_name>

# Rename any local branch
git branch -m old_branch new_branch

# Verify branch
git branch
# remote
git branch -r

# Push renamed branch to remote and delete the old one on remote
git push origin -u new_branch
git push origin --delete old_branch

# Remove a local branch
git branch -d branch_name
# force
git branch -D branch_name

# Remove a remote branch
git push origin --delete branch_name

Stage and unstage

# Stage File
git add <file>

# Stage multiple files
git add <file_1> <file_2>

# Stage All Changes
git add .

# Unstage File
git restore --staged <file>
# or
git reset <file>

# Unstage All Changes
git reset

Discard changes (don’t apply for newly created files)

# Discard changes in a file
git restore <file>

# Discard all changes (unstaged)
git restore .

# Discard all staged and unstaged
git reset --hard

Pull

# Fetch All
git fetch --all

# fast-forward (if possible) <- it will perform a merge after the pull
git pull --ff

# fast-forward only (only pull, not merge)
git pull --ff-only

# rebase <- move all local changes on top of the remote changes
git pull --rebase

Rebase

# Rebase current branch (b1) onto (dev)
git rebase dev

# If there are conflicts -> modify manually and then
git add file_name
git rebase --continue

# Abort the rebase
git rebase --abort

# Force push b1 after the rebase
git push origin b1 --force

Merge

# Merge current branch (b1) into (dev)
git checkout dev
git merge b1

# If there are conflicts -> modify manually and then
git add file_name
git commit

# Check the commit history
git log --graph --decorate --oneline

Stash and Pop