0% found this document useful (0 votes)
403 views

Git - The Simple Guide - No Deep Shit! PDF

This document provides a simple 3-page guide to getting started with the version control system Git. It begins with instructions on setting up Git and creating repositories. It then covers basic Git workflows like adding, committing, and pushing changes. Additional sections explain branching, merging, tagging, viewing logs, replacing local changes, and other useful Git commands and concepts. Throughout, it emphasizes that this is a no-nonsense guide without complex details.

Uploaded by

Ramya Murugan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
403 views

Git - The Simple Guide - No Deep Shit! PDF

This document provides a simple 3-page guide to getting started with the version control system Git. It begins with instructions on setting up Git and creating repositories. It then covers basic Git workflows like adding, committing, and pushing changes. Additional sections explain branching, merging, tagging, viewing logs, replacing local changes, and other useful Git commands and concepts. Throughout, it emphasizes that this is a no-nonsense guide without complex details.

Uploaded by

Ramya Murugan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

1/8/2015

git - the simple guide - no deep shit!

git - the simple guide


justasimpleguideforgettingstartedwithgit.nodeepshit)
Tweet

4,747

byRogerDudler
creditsto@tfnico,@fhdandNamics
thisguideindeutsch,espaol,franais,italiano,nederlands,portugus,,trke,
,,,Vietnamese
pleasereportissuesongithub

setup
DownloadgitforOSX
DownloadgitforWindows
http://rogerdudler.github.io/git-guide/

1/14

1/8/2015

git - the simple guide - no deep shit!

DownloadgitforLinux

create a new repository


createanewdirectory,openitandperforma
git init
tocreateanewgitrepository.

checkout a repository
createaworkingcopyofalocalrepositorybyrunningthecommand
git clone /path/to/repository
whenusingaremoteserver,yourcommandwillbe
git clone username@host:/path/to/repository

http://rogerdudler.github.io/git-guide/

2/14

1/8/2015

git - the simple guide - no deep shit!

workflow
yourlocalrepositoryconsistsofthree"trees"maintainedbygit.thefirstoneis
your Working Directory whichholdstheactualfiles.thesecondoneis
the Index whichactsasastagingareaandfinallythe HEAD whichpoints
tothelastcommityou'vemade.

add & commit


Youcanproposechanges(addittotheIndex)using
git add <filename>
git add *
Thisisthefirststepinthebasicgitworkflow.Toactuallycommitthese

http://rogerdudler.github.io/git-guide/

3/14

1/8/2015

git - the simple guide - no deep shit!

changesuse
git commit -m "Commit message"
NowthefileiscommittedtotheHEAD,butnotinyourremoterepositoryyet.

pushing changes
YourchangesarenowintheHEADofyourlocalworkingcopy.Tosendthose
changestoyourremoterepository,execute
git push origin master
Changemastertowhateverbranchyouwanttopushyourchangesto.

Ifyouhavenotclonedanexistingrepositoryandwanttoconnectyour
repositorytoaremoteserver,youneedtoadditwith
git remote add origin <server>
Nowyouareabletopushyourchangestotheselectedremoteserver

branching
http://rogerdudler.github.io/git-guide/

4/14

1/8/2015

git - the simple guide - no deep shit!

Branchesareusedtodevelopfeaturesisolatedfromeachother.Themaster
branchisthe"default"branchwhenyoucreatearepository.Useotherbranches
fordevelopmentandmergethembacktothemasterbranchuponcompletion.

createanewbranchnamed"feature_x"andswitchtoitusing
git checkout -b feature_x
switchbacktomaster
git checkout master
anddeletethebranchagain
git branch -d feature_x
abranchisnotavailabletoothersunlessyoupushthebranchtoyourremote
repository
git push origin <branch>

http://rogerdudler.github.io/git-guide/

5/14

1/8/2015

git - the simple guide - no deep shit!

update & merge


toupdateyourlocalrepositorytothenewestcommit,execute
git pull
inyourworkingdirectorytofetchandmergeremotechanges.
tomergeanotherbranchintoyouractivebranch(e.g.master),use
git merge <branch>
inbothcasesgittriestoautomergechanges.Unfortunately,thisisnotalways
possibleandresultsinconflicts.Youareresponsibletomergethoseconflicts
manuallybyeditingthefilesshownbygit.Afterchanging,youneedtomark
themasmergedwith
git add <filename>
beforemergingchanges,youcanalsopreviewthembyusing
git diff <source_branch> <target_branch>

tagging
it'srecommendedtocreatetagsforsoftwarereleases.thisisaknownconcept,
whichalsoexistsinSVN.Youcancreateanewtagnamed1.0.0byexecuting
http://rogerdudler.github.io/git-guide/

6/14

1/8/2015

git - the simple guide - no deep shit!

git tag 1.0.0 1b2e1d63ff


the1b2e1d63ffstandsforthefirst10charactersofthecommitidyouwantto
referencewithyourtag.Youcangetthecommitidbylookingatthe...

log
initssimplestform,youcanstudyrepositoryhistoryusing.. git log
Youcanaddalotofparameterstomaketheloglooklikewhatyouwant.To
seeonlythecommitsofacertainauthor:
git log --author=bob
Toseeaverycompressedlogwhereeachcommitisoneline:
git log --pretty=oneline
OrmabeyouwanttoseeanASCIIarttreeofallthebranches,decoratedwith
thenamesoftagsandbranches:
git log --graph --oneline --decorate --all
Seeonlywhichfileshavechanged:
git log --name-status
Thesearejustafewofthepossibleparametersyoucanuse.Formore,see
git log --help

http://rogerdudler.github.io/git-guide/

7/14

1/8/2015

git - the simple guide - no deep shit!

replace local changes


Incaseyoudidsomethingwrong(whichforsureneverhappens)youcan
replacelocalchangesusingthecommand
git checkout -- <filename>
thisreplacesthechangesinyourworkingtreewiththelastcontentinHEAD.
Changesalreadyaddedtotheindex,aswellasnewfiles,willbekept.
Ifyouinsteadwanttodropallyourlocalchangesandcommits,fetchthelatest
historyfromtheserverandpointyourlocalmasterbranchatitlikethis
git fetch origin
git reset --hard origin/master

useful hints
builtingitGUI
gitk
usecolorfulgitoutput
git config color.ui true
http://rogerdudler.github.io/git-guide/

8/14

1/8/2015

git - the simple guide - no deep shit!

showlogonjustonelinepercommit
git config format.pretty oneline
useinteractiveadding
git add -i

links & resources


graphicalclients
GitX(L)(OSX,opensource)
Tower(OSX)
SourceTree(OSX&Windows,free)
GitHubforMac(OSX,free)
GitBox(OSX,AppStore)

guides
GitCommunityBook
ProGit
Thinklikeagit
GitHubHelp
AVisualGitGuide

gethelp
GitUserMailingList
#gitonirc.freenode.net

http://rogerdudler.github.io/git-guide/

9/14

1/8/2015

git - the simple guide - no deep shit!

comments
374Comments

gitthesimpleguide

Login

Share Favorite

SortbyNewest

Jointhediscussion
rcn 5daysago

somaybeI'mmisuderstandinggit..butIhaveaworkingdirectorywithonefileinit,andI
madeabranchnamed"develop"tomodifythatfilewhichinvolvedbreakingitfor
awhile.however,IjustrealizedthatifIgitcheckoutbetweenmymasteranddevelop
branch,thatfileisexactlythesameinbothbranches,iewhat'sthepointofmakinga
separatebranchtotestchangesinifit'smodifyingthefileinmymasterbranchaswell?
wassurprisedthathappened,maybeI'mdoingsomethingwrong?

Reply Share

SeijiNaganuma>rcn 4daysago

ThewayIlookatbranchesisthattheyarepointerstocommitsorsnapshotsyou
havemade.Whenyoucreateandcheckoutthenewbranch,you'reonlygoingto
movethe"develop"pointerforward.Onceyoucheckoutthemasterbranch,
you'removingthe"master"pointereachtimeyoumakeacommit.
Tomakethemasteranddevelopbranchestheexactsameyoueitherhadtohave
mergedthetwobranchestogetherormistakenlymadechangesonthewrong
branch.
Oneimportantpointtorememberisthatcreatinganewbranchdoesn't
automaticallycheckoutthatbranch.Youneedtorun"gitbranchdevelop"then
"gitcheckoutdevelop"orrun"gitcheckoutbdevelop".

Reply Share

rcn>SeijiNaganuma 4daysago

maybeIaccidentallydiditwithoutcheckingouttoadifferentbranch,I'm
notsure.So,ifI'minmyworkingdirectory(thelocalfolderonmyactual
computer)whereIinitializedgit,andIgitcheckouttoanewbranch,then
Iopenandeditmyfile(inthenewbranch)inmytexteditor,saveitand
exitout..howdoesgittelltheactuallocalfilethatit'ssupposedtohave
twoinstances?(ontwoseparatebranches).Inthatscenario,theonlyfile
thatshouldhavethechangesistheonethat'sinthebranchIeditedit
from,correct?

Reply Share

SeijiNaganuma>rcn 3daysago

theworkingdirectorywilllooklikeyourbranchthatyou
checkout.SoifyoudoworkonDevelopandthencheckout
Master,yourworkingdirectorywillchange.Gitwillmakesure
thatthereisnouncommittedchangesbeforeyoucheckouta
differentbranch.Theinformationforthedifferentbranchesare
storedinyou.gitfolder.

Reply Share

MeteorFury 6daysago

Yeah,thisisexactlywhatIneeded.Goodbasictutorial.

Reply Share

UmerJafer 9daysago

http://rogerdudler.github.io/git-guide/

10/14

1/8/2015

git - the simple guide - no deep shit!

GreatTutorial!BestforanyonecomingfromSVNorsomeotherrepowhodon'tneedno
deepshit)
1

Reply Share

sidn 14daysago

Awesometutorial!Thanksalot!:)
3

Reply Share

lmayorga 18daysago

Sorryaboutthatnewtosocialmediaofanysort.Apparentlyneedtoworkondragging
anddropping.
1

Reply Share

lmayorga 18daysago

I'mforeverinyourdebtforprovidingabigpicturecontextformyisolatedinsights!

Reply Share

JAYTECH 20daysago

SuperHelpful!Thankyousomuch!
1

Reply Share

TomasDrozda 22daysago

Awesome:)

Reply Share

fasflow 22daysago

Thanksalotforthistuto/memoofgit!Iloveit!!Andwhataflatdesignwebsite!
*APPLAUSE*

Reply Share

thekngmkr 22daysago

Dude...justmademyday...nodeepshit...haha
3

Reply Share

MattRhysDavies 22daysago

Absolutelybrilliantthankyou.WishIhadfoundthisguidewhenIwasfirststartingout
withGit!
3

Reply Share

AndyHidayat 24daysago

awesometutorials...great!!!!

Reply Share

NickJacobs 25daysago

So,so,sohelpful.Gitisoneofthosetoolswhereeverythingisfamiliarandyetdifferent
atthesametime.Thanks!

Reply Share

akyan amonthago

reallyhelpful!Thanks!

Reply Share

NeoIndia amonthago

Best!Youproveditthingscanbesimpleandgreat!
Cheers,
Neo
http://rogerdudler.github.io/git-guide/

11/14

1/8/2015

git - the simple guide - no deep shit!

Neo

Reply Share

Haren amonthago

Itisreallyhelpful.....alreadybookmarkedthispage.

Reply Share

Jin amonthago

hi!ijustwanttoaskwhatifitisaskingmetostashmychanges?whatshouldido?
thanks!
2

Reply Share

VineethReddy>Jin amonthago

canyoubespecificwhengitaskedyoutostashyourchanges.
Ingeneral,stashingby"gitstash"removesallchangesfromstagingareaand
modifiedareaandaresavedit.gitfolder.You'llthenhaveacleanslatewithout
anychanges.Youneednotworryaboutallyourchanges,youcanreapplythem
using"gitstashapply"
1

Reply Share

LudovicHenin amonthago

Yourcommentslistisinsanebud.
Butwhatanawesomepage.Thanks.

Reply Share

nihat amonthago

awesometutorial,thanks!

Reply Share

AllenStroy amonthago

Loveit!Greatsimpleoverview!!!

Reply Share

PhmSinh amonthago

thanksyou!great
1

Reply Share

IvanLozo amonthago

great,thankyou!

Reply Share

JooCarlosFerreira amonthago

Thisisreallyhelpful!
Thanksforthepost

Reply Share

ShonFeder amonthago

thankyou!Iwillbereferringbackoften.
1

Reply Share

TweetsOfSumit amonthago

ha!Goodstuff,thanks!

Reply Share

berkapavel amonthago

reallyhelpful...thankyou

Reply Share

ashwin amonthago

thankssssssss

Reply Share

JoeDougherty amonthago

Greatguide.I'vebeenontheperipheralofgitforalongtime,nowIneeditandthis
makesalotclear.Greatsite,andthanks.
http://rogerdudler.github.io/git-guide/

12/14

1/8/2015

git - the simple guide - no deep shit!


makesalotclear.Greatsite,andthanks.

Reply Share

RocoGarcaLuque amonthago

Precious:)

Reply Share

JerryMarshall 2monthsago

greatguide,thanks!!

Reply Share

pshinoj 2monthsago

ThisisreallyusefulforGitHubstarters!Thanks

Reply Share

RajeshMule 2monthsago

Hi,IhavecreatedanAndroidappbasedonthiswebsitethatworksofflineandhasallthe
awesomenessofthewebsite.Hopeithelpsmorepeople.Happylearning:)
https://play.google.com/store/...
2

Reply Share

DmitriyUsakov 2monthsago

oneofthebesttutorialforbeginner!Thanks

Reply Share

JiriDanecek 2monthsago

IhavereadalotofstuffaboutgitbutforthefirsttimeIknowhowtouseit

Reply Share

DWisehart 2monthsago

'gitstatus'isanotherbasiclevelcommandthatwouldbegoodtolist.Easiertoremember
than'gitcommitdryrun'.

Reply Share

Uday 2monthsago

Awesome,thanksaton:)

Reply Share

saeedraeesmohammadi 2monthsago

Thanksalot!

Reply Share

JinalKothari 2monthsago

Thanksaton!!Thisissuperhelpful!!!!!!

Reply Share

DanielGarcaPez 2monthsago

Theperfectguide!

Reply Share

NicholasLawson 2monthsago

JustwhatIwaslookingfor.

Reply Share

Deepak 2monthsago

Indeedasimple,helpful&amazingguide!!
Thanksforyoureffortsforputtingupsuchauseful&concisetutorial

Reply Share

Bob 2monthsago

Bestguideever,itnowallmakessensethankssomuch!

Reply Share

William 2monthsago

Greatguide!
http://rogerdudler.github.io/git-guide/

13/14

1/8/2015

git - the simple guide - no deep shit!

Reply Share

JohnZhao 2monthsago

Greatestguideforbeginners!

Reply Share

AndriiKuplevakhskyi 2monthsago

HelloRoger,
manythanksforsuchaguide!Itseemstobeveryusefulfornewbies.
I'dliketotranslatetheguideintoUkrainian.I'lltryyoplaywiththesourcesonGitHubto
doit.We'llseehowitgoes.
Please,letmeknowifyouhaveanythoughts/objections.
Cheers,

Reply Share

mahdi 2monthsago

Thankssomuch

Reply Share

Loadmorecomments

WHAT'STHIS?

ALSOONGITTHESIMPLEGUIDE

gitguiaprticosemcomplicao!

git

73comments2yearsago

5commentsamonthago

PrapathNuiSuayroop

BrunoBarcellosEsselivro


Text

distribudogratuitamenteatravsdalicena
CreativeCommons,logono

git!
1comment2yearsago

dsssssssswhatagoodsite

gitDereinfacheEinstiegkein
Schnickschnack!
33comments2yearsago

tkHatmirsehrgeholfen.Danke!

Subscribe

http://rogerdudler.github.io/git-guide/

AddDisqustoyoursite

Privacy

14/14

You might also like