From 40303cb79f64611aad1139bd1663c9f253f2f686 Mon Sep 17 00:00:00 2001 From: Erfan Ansari Date: Thu, 14 Oct 2021 20:12:34 +0330 Subject: [PATCH] Update git --- tools/git.sh | 87 ++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 81 insertions(+), 6 deletions(-) diff --git a/tools/git.sh b/tools/git.sh index 46573a0..c7048d0 100644 --- a/tools/git.sh +++ b/tools/git.sh @@ -4,15 +4,32 @@ git clone
# creates a git repo from given address (get the address fro 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 file.txt # adds(stages) file.txt to the git +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 @@ -32,7 +49,13 @@ git remote add my-remote
# creates a remote (get the address from your 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=