git init # initiates git in the current directory
git remote add origin https://github.com/repo_name.git # add remote reposiory
git clone
# creates a git repo from given address (get the address from your git-server)
git clone -b # clones a git repo from the address into the given directory and checkout's the given branch
git clone -b --single-branch # Clones a single branch
git add # adds(stages) file.txt to the git
git add * # adds(stages) all new modifications, deletions, creations to the git
git reset file.txt # Removes file.txt from the stage
git reset --hard # Throws away all your uncommitted changes, hard reset files to HEAD
git reset --soft # moves the head pointer
git reset --mixed # moves the head pointer and then copies the files from the commit it is now pointing to the staging area,
# the default when no argument is provided
git reset -hard # moves the head pointer and then copies the files from the commit it is now pointing to the staging area
# and working directory thus, throw away all uncommitted changes
# git reset
# 1. Move HEAD and current branch
# 2. Reset the staging area
# 3. Reset the working area
# --soft = (1)
# --mixed = (1) & (2) (default)
# --hard = (1) & (2) & (3)
git rm file.txt # removes file.txt both from git and file system
git rm --cached file.txt # only removes file.txt both from git index
git status # shows the modifications and stuff that are not staged yet
git branch # shows all the branches (current branch is shown with a star)
git branch -a # shows all the branches local and remote
git branch my-branch # creates my-branch
git branch -d my-branch # deletes my-branch
git checkout my-branch # switches to my-branch
git merge my-branch # merges my-branch to current branch
git push origin --delete my-branch # delete remote branch
git branch -m # rename the branch
git checkout --orphan # checkout a branch with no commit history
git branch -vv # list all branches and their upstreams, as well as last commit on branch
git branch -a # List all local and remote branches
git cherry-pick # merge the specified commit
git cherry-pick ^.. # pick the entire range of commits where A is older than B ( the ^ is for including A as well )
git remote # shows the remotes
git remote -v # shows the remote for pull and push
git remote add my-remote # creates a remote (get the address from your git-server)
git remote rm my-remote # Remove a remote
git log # shows the log of commits
# git log by default uses less command so you can use these: f=next page, b=prev page, search=/, n=next match, p=prev match, q=quit
git log --no-pager # shows the log of commits without less command
git log --oneline # shows the log of commits, each commit in a single line
git log --oneline --graph --decorate # shows the log of commits, each commit in a single line with graph
git log --since=