0% found this document useful (0 votes)
148 views1 page

GIT Cheat Sheet

The document provides a comprehensive list of Git commands along with their descriptions. It includes commands for initializing repositories, managing branches, pushing and pulling changes, and configuring user settings. Each command is paired with a brief explanation of its purpose and usage.

Uploaded by

gopinavuluri2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
148 views1 page

GIT Cheat Sheet

The document provides a comprehensive list of Git commands along with their descriptions. It includes commands for initializing repositories, managing branches, pushing and pulling changes, and configuring user settings. Each command is paired with a brief explanation of its purpose and usage.

Uploaded by

gopinavuluri2000
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

ShÿóeþÿôøþUpøÿõe

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

Rf  DvOp L fy Commands Description


commit

     git status To know the status


git pull origin [branch name] To pull the changes from a remote
repository
Í ‡\‰01-CŠZn•ngR‰Zˆ•\Z y:Cà6C256C=>9<1<*C,.6C=9)6C
,.2,C56?1)6?C1<C,.6C56A9,6C56-9?1,95/C,9CA2B6C2C>9=2>C git diff Displays what has been changed but git remote add origin ssh://[email protected]/ To add a remote repository

! " % Í


56-9?1,95/C9<C905C?/?,6
‡\‰02-Add•ngCh†ngˆ:Cà6C-65+95ACA0>,1->6C
not staged yet. [username]/[repository-name].git

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-PuŠŠ•ngCh†ngˆ‹ ZmRmZ\R‰Zˆ•\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

the changes in the working directory.


(.6<C76C-0>>C,.6C+1>6?C2*21<C+59AC,.6C56A9,6C56-9?1,95/C remote repository.
(6=.<1=2>>/4C365?19<C=9<,59>C1?C,.6CA2<2*6A6<,C9+C=.2<*6?C ,9C=.6=BC1+C?9A69<6C.2?CA2)6C?9A6C56=6<,C=.2<*6?C95C git commit -m “[descriptive message]” Commit your staged content
A2)6C,9C,.6C=9)64C)9=0A6<,?4C-59*52A?4C2<)C9,.65C <9,© R eùóýõeþHýsõûóy
1<+95A2,19<:C(.6C=.2<*6?C256C56+6556)C,9C2?C365?19<?: Í ‡\‰04-R’•[•ng\hCZd:Cà6CR63167C,.6C=.2<*6?4C
git diff --staged Displays what has been staged but
not committed yet.

(.656C256C\[ZC,/-6?C9+C365?19<C=9<,59>C?/?,6A?a A936C,.6C=9)6C,9C,.6C?,2*1<*C25624C2<)C56A936C2</C Commands Description


git commit --amend -m “new_ message” To amend the last commit or the last
H T6<,52>1S6)CF65?19<CT9<,59>Cb/?,6ACETFTb^ =9<+>1=,C-56?6<,C1<C,.6C=9)6© message

H D1?,51G0,6)CF65?19<CT9<,59>Cb/?,6ACEDFTb] Í ‡\‰05-CZmm•\\•ngCh†ngˆ: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

Í LZ„†Š ‰Zˆ•\Z y:C8,C1?C2C>9=2>C)156=,95/C,.2,C=9<,21<?C,.6C Commands Description


=9)6C+1>6?C+95C,.6C-59›6=,© T empûóÿóyþCûmmýõ
git branch To list branches
Í RmZ\ ‰Zˆ•\Z y:C8,C1?C2<C9<>1<6C365?19<C9+C,.6C>9=2>C
git branch -a To list all the branches
56-9?1,95/C,.2,C1?C.9?,6)C9<C?6531=6?C>1B6Ck1, 0G4Ck1,¤2G4C Commands Description
2<)Cê1,ê0=B6,© git branch [branch name] To create a new branch
Í CŠZn•ng:C(.6C2=,C9+CA2B1<*C2C=>9<6C95C=9-/C9+C2C git stash To stash the changes in a dirty working directory
git branch -d [branch name] To delete a branch
56-9?1,95/C1<C2C<67C)156=,95/©
Í CZmm•\:C 8,C1?C2C?<2-?.9,C9+C,.6C-59›6=,’?C?,2*6)C git push origin –delete [branchName] To delete a remote branch
git stash pop W rite working from the top of the stash stack.
=.2<*6?© git checkout -b [branch name] To create and switch to a new branch
Í B †n„h:C˜CG52<=.C1?C2C=9-/C9+C,.6C-59›6=,C0?6)C+95C git stash list List the stack-order of stashed file changes.
git checkout -b [branch name] origin/[branch To clone and switch to a remote
795B1<*C1<C2<C1?9>2,6)C6<3159<A6<,C71,.90,C2++6=,1<*C,.6C
05CD63-?C,99>4Ck1,4C+2>>?C0<)65C,.6C=2,6*95/C9+CD1?,51G0,6)C name] branch git stash drop Discard the changes from the top of the stash
A21<C-59›6=,© stack.
FTb: git checkout [branch name] To switch to a branch
Í •\m g:C(.6C-59=6??C9+C=9AG1<1<*C,79CG52<=.6?C1<C
git stash clear To remove all the stashed entries
k1,© git checkout – To switch to the branch last checked
!  % Í .g•\•gnZ ‹•Š:C8,C1?C2C+1>6C,.2,C?-6=1+16?C1<,6<,19<2>>/C  3 mm out

•\1?C2C+566C2<)C9-6<²?905=6CŽ’‘‰ˆC,99>C0?6)C2?C2C Í
0<,52=B6)C+1>6?C,.2,Ck1,C?.90>)C1*<956©
‡\†g•ng† †:C˜C=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<0ŸC-652,1<*Cb/?,6ACœ65<6>C1<Cž¿¿Á;
8,C1?C2C56-9?1,95/C0?6)C,9CA2<2*6C2C-59›6=,@?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•\IސZ h†ˆh:C˜C0<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ˆ„†‰•\†Š•zdŠ\\ ˆ):C˜C56+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<0ŸCA2=.1<6?Ð 7.1=.C1?C2>?9C,.6CA21<C-59›6=,C)636>9-A6<,C6<3159<A6<,:

You might also like