gukbi

Git

clone

# This clones from remote to local in directory named 'Repository'
git clone https://github.com/UserName/Repository.git
# This clones from remote to local in current directory
git clone https://github.com/UserName/Repository.git .

init

# This creates init files for git in current directory with branch named 'main'
git init --initial-branch=main

commit

# This creates commit with staged files
git commit -m 'Commit Message'
# This edits current commit
git commit --amend

remote

add

# This adds remote named 'origin' with url
git remote add origin https://github.com/UserName/Repository.git

set-url

# This sets url of remote named 'origin'
git remote set-url origin https://github.com/UserName/Repository.git

rebase

# Usage
git rebase -i HEAD~5

pull

# This pulls from remote
# WARNING : somehow remote and local edit any same files, it occurrs conflicts
git pull

–rebase

# This can pull when you commited early than remote and you want to pull
# WARNING : somehow remote and local edit any same files, it occurrs conflicts
git pull --rebase

fetch

merge

branch

# Creates branch named 'sub' force-fully from HEAD
git branch -f sub

checkout

# This goes in to branch named 'sub'
git checkout sub