GIT Cheat Sheet
GIT Cheat Sheet
SeõupþÿôøþIôýõýÿúýzÿõýûô
üûùôúûÿøþöýõþ÷ûóþòÿñðþhõõpsð//gýõ-sñm.ñûm/øûùôúûÿø/mÿñ
Commands Description
üûùôúûÿøþöýõþ÷ûóþWýôøûùsðþhõõpsð//gýõ-sñm.ñûm/øûùôúûÿø/ùýô Commands Description
git push origin [branch name] To push a branch to a remote repository
git init Initialize an existing directory.
üûùôúûÿøþöýõþ÷ûóþLýôuxðþhõõpsð//gýõ-sñm.ñûm/øûùôúûÿø/úýôux
git push -u origin [branch name] To push the changes made to a remote
git clone [url] Retrieve the repository from the hosted location repository (-u remember the branch for the
through the URL.
next use)
2Ì g git push origin –delete [branch name] To delete a remote branch
SõÿgýôgþÿôøþSôÿpshûõs
git pull To update a local repository to the newest
git add [file] To add a file git remote set-url origin ssh:// To set a repository s origin branch to SSH
’
9-652,19<?C95C=.2<*6?C>1B6C6)1,1<*C2C+1>64C2))1<*C<67C [email protected]/[username]/[repository-
8<C>2/A2<@?C,65A?4C365?19<C=9<,59>4C2>?9CB<97<C2?C?905=6C =9)64C)6>6,1<*C-563190?C=9)64CA931<*C+1>6?4C6,=©
git add [filename] [2nd filename] [3rd filename] To add multiple files name].git
=9<,59>4C1?C,.6C-52=,1=6C9+C,52=B1<*C2<)CA2<2*1<*C=.2<*6?C Í \03-PungChng ZmRmZ\RZ\Z y:C git reset [file] Used to unstage a file while keeping git fetch [alias] etch all the branches from that hosted
,9C?9+,7256C=9)6;
F
H D1?,51G0,6)CF65?19<CT9<,59>Cb/?,6ACEDFTb] Í \05-CZmm\\ngChng:Cà6C+1<2>>/C=9AA1,C,.6C git rebase [branch] Used to integrate changes from one branch into
another branch.
=.2<*6?C71,.C2C-59-65C=9AA1,CA6??2*6:
Kym g Bóÿôñhþÿôøþòeóge
git reset --hard [commit] Used to reset the current branch to a specific
commit
\1?C2C+566C2<)C9-6<²?905=6CC,99>C0?6)C2?C2C Í
0<,52=B6)C+1>6?C,.2,Ck1,C?.90>)C1*<956©
\gng :CC=2=.6C,.2,C.9>)?C=.2<*6?C,.2,C71>>C*9C
git checkout — [file-name.txt] Used to discard any changes made
to a file
4 mmy
öýõþñûô÷ýguóÿõýûô
365?19<C=9<,59>C?/?,6A:C8,C72?C=562,6)CG/C¤1<0?C(9532>)?4C,.6C 1<,9C/905C<6,C=9AA1,© git merge [branch name] To merge a branch into an active
=562,95C9+C,.6C¤1<0C-652,1<*Cb/?,6AC65<6>C1<C¿¿Á;
8,C1?C2C56-9?1,95/C0?6)C,9CA2<2*6C2C-596=,@?C365?19<C95C?6,C
Í \\h:C<9,.65C,/-6C9+C=2=.6C,.2,C.9>)?C0<72<,6)C
=.2<*6?C/90CA2/C72<,C,9C56,05<C,9C>2,65© Commands Description
branch
Hw mm!k%
9+C+1>6?C2?C,.6/C=.2<*6C9365C,1A6:C 6564CA0>,1->6C)636>9-65?C Í CZmm\IZ hh:CC0<1q06C1)6<,1+165C+95C62=.C=9AA1,4C IôspeñõþÿôøþCûmpÿóe
git config --global user.name Set the global configuration for the Git
=2<C=9<,51G0,6C,9C,.6C=9)6C?1A0>,2<690?>/:C8,C2>?9C?0--95,?C 0?6)C+95C?71,=.1<*C,9C)1++656<,C?236C-91<,?©
“[firstname lastname]” user's name.
2C<9<²>1<625C72/C9+C)636>9-A6<,C7.656C/90C=2<CA2B6C Í HEA([y\zd\\ ):CC56+656<=6C<2A6C+95C
Commands Description
A0>,1->6CG52<=.6?C+95C62=.C<67C+62,056; ,.6C>2,6?,C=9AA1,4C,9C?236C/90C+59AC.231<*C,9C,/-6C git config --global user.email Set the global configuration for the Git
“[valid-email]” email.
==95)1<*C,9C2C?0536/CG/C\ Z[Cª¸»C9+C,.6C =9AA1,C8D?: git log Show the commit history
)636>9-65?C256C0?1<*Ck1,C2?C,.615CF65?19<CT9<,59>C(99>: git config --global color.ui auto Enable automatic coloring for Git output,
git diff branchB...branchA Show the difference between branchA and
B
i.e., Git will automatically colorize its output
branchB
when it's going to a terminal.
Ì git config --list Displays the current configuration settings
git log branchB..branchA Show the commits on branchA that are not
there on branchB
ê52<=.6?C256C?-6=12>C=9-16?C9+C,.6C=9)6CG2?6C,.2,C2>>97C for Git on your system.
k1,C=2<CG6C1<?,2>>6)C9<C9-652,1<*C?/?,6A?C>1B6Cà1<)97?4C /90C,9C795BC9<C<67C+62,056?C1<C2<C1?9>2,6)C6<3159<A6<,:C(.6C git log --follow [file] Show the commits that changed the file
Ö2=4C2<)C¤1<0:Cê/C)6+20>,4Ck1,C1?C-56²1<?,2>>6)C9<CÖ2=C2<)C =.2<*6?CA2)6C1<C2CG52<=.C79<’,C2++6=,C,.6CA21<CG52<=.4C git show [SHA] Show any object in a human-readable format
¤1<0CA2=.1<6?Ð 7.1=.C1?C2>?9C,.6CA21<C-596=,C)636>9-A6<,C6<3159<A6<,: