Git - The Simple Guide - No Deep Shit! PDF
Git - The Simple Guide - No Deep Shit! PDF
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
DownloadgitforLinux
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
workflow
yourlocalrepositoryconsistsofthree"trees"maintainedbygit.thefirstoneis
your Working Directory whichholdstheactualfiles.thesecondoneis
the Index whichactsasastagingareaandfinallythe HEAD whichpoints
tothelastcommityou'vemade.
http://rogerdudler.github.io/git-guide/
3/14
1/8/2015
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
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
tagging
it'srecommendedtocreatetagsforsoftwarereleases.thisisaknownconcept,
whichalsoexistsinSVN.Youcancreateanewtagnamed1.0.0byexecuting
http://rogerdudler.github.io/git-guide/
6/14
1/8/2015
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
useful hints
builtingitGUI
gitk
usecolorfulgitoutput
git config color.ui true
http://rogerdudler.github.io/git-guide/
8/14
1/8/2015
showlogonjustonelinepercommit
git config format.pretty oneline
useinteractiveadding
git add -i
guides
GitCommunityBook
ProGit
Thinklikeagit
GitHubHelp
AVisualGitGuide
gethelp
GitUserMailingList
#gitonirc.freenode.net
http://rogerdudler.github.io/git-guide/
9/14
1/8/2015
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
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
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
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
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