NCARB Checkout Git
-
Upload
davedavious -
Category
Technology
-
view
211 -
download
0
Transcript of NCARB Checkout Git
NCARBCHECKOUTGIT
TOPICSINTHISTALKIntroductionDesignGoalsArchitectureUsingGit-Basics-Branching-CollaborationGitwithVisualStudioGitHub
GITCULTUREEverythingisaFeatureBranchCommitoftenasworkprogressesDevelopersdon'taskforpermission:CloneandsendapullrequestMaintainerspickandchoosewhattomergeDelegatednetworkoftrust
HISTORYDevelopedinApril2005byLinusTorvalds
PREGITLinuxCollaboratorsworkedwithpatches
thenBitkeeperandfallout
NOWMaintainedbyJunioHamano
DESIGNGOALSDistributedReliableQuick
ACHIEVEDTHROUGHARCHITECTUREANDGOODCODE
DISTRIBUTEDTheentirerepositoryiscopied.
Repositoryworkisdoneofflinebecauseyouhavethewholerepositorywithyou.
RELIABLEEachobject'sfilenameisitshash:
easytoverify.
DISTRIBUTED==RELIABLEIfyourrepositoryislost,
justaskforanotherdeveloper'scopy.
GITFEATURE:QUICKSnapshots,notdiffs.
Fastoperationsonswitching,merging,andcommitting.
Simplearchitecturewithkernelhackerrefinements.
DISTRIBUTED==QUICKAlloperationsarelocal.
ARCHITECTURE
EACHOBJECT'SFILENAMEISITSHASH
OBJECTSFiles,Directories,Commits
POINTERSBranches,HEAD,Tags
OBJECTSHello.txt
e965047ad7c57865823c7d992b1d046ea66edf78
Hello\n
DirectoryContainingHello.txt2ea873e13e84497d7459150a0b2b662403e3bc2b
100644blobe965047ad7c57865823c7d992b1d046ea66edf78Hello.txt
CommitofDirectoryContainingHello.txt849d9a4ec0e853151ca4e8ff630feee25d701386
tree2ea873e13e84497d7459150a0b2b662403e3bc2bparent2dce1bf1497951717f34a3a0d9605436e0477832authorDAnderson<[email protected]>1375967945-0400committerDAnderson<[email protected]>1375968283-0400
CommittedHello.txt
POINTERSMasterBranch
.git/refs/heads/master
849d9a4ec0e853151ca4e8ff630feee25d701386
HEAD.git/HEAD
ref:refs/heads/master
config.git/config(snippet)
[remote"origin"]url=https://github.com/davious/PrepGit.gitfetch=+refs/heads/*:refs/remotes/origin/*[branch"master"]remote=originmerge=refs/heads/master
USINGGITBasicsBranchingCollaboration
BASICSSetupaRepositoryStageFilesCommitStagedFilesUndoChangesTagging
SETUPAREPOSITORYCREATEAREPOSITORY
gitinit
Createsarepositoryfilesysteminthe.gitsubdirectory
SETNAMEANDEMAILgitconfiguser.name"DAnderson"gitconfiguser.email"[email protected]"
Usedinallcommitfiles
Stagesfiles;filesarenowtracked.
STAGEFILESgitadd.
Furthermodificationstothesamefileremainunstageduntilthenextadd.
Showswhichfilesaretracked,whichfilesaremodified
Showsline-by-linechangesbetweenmodifiedandstaged/committed
Showsline-by-linechangesbetweenstagedandcommitted
gitstatus
gitdiff
gitdiff--cached
Amendisaneasywaytoaddtowhatwasjustcommitted
COMMITFILESgitcommit-m"Commitmessage"
Branchnowpointstonewcommitfile.Commitfilespointtopreviousparent(s).
gitcommit-m"Commitmessage"--amend
orjustredothecommitmessage
gitlog
Reviewpastcommits
UNDOINGTHINGSgitcheckout--filename1filename2gitclean-f
Revertunstagedchangedtotheirstagedorcommittedstate;cleandeleteduntrackedfiles
gitresetHEADgitresetHEADfilename1filename2
Unstagestagedfilesgitreset--hard
Throwawayallworkgitreset--hardHEAD^2
Undolasttwocommits
TAGGINGgittag-a2.0-m"MidAugustRelease"
Addsatagonbranch'slastcommit
gitdescribe2.0-12-8bd3fe1
Currentcommitdescriptionbasedonlastcreatedtag
{lasttagname}-{revisionssince}-{shorthashofcommit}
BRANCHESEthosCreatingMergingResolvingConflictsRebasingSquashing
BRANCHETHOSBranching,Checkingout,andMergingischeapandfastItkeepsthemasterbranchgoldenWebranchwithinourownrepositories;so,themainrepositoryremainsuncluttered
SO,FOREACHENDEAVOR,BRANCH
Switchesyourworkingfilestothisbranchesfiles
Shortcut:createsthebranchandchecksitout
BRANCHCREATIONgitbranchnewbranch#master,newbranch>>A;HEAD>>master
Createsanewbranch
gitcheckoutnewbranch#HEAD>>abranch
Note:Anystagedfilesremainedstaged
gitcheckout-bnewbranch#master,newbranch>>A;HEAD>>abranch
newbranchisnowyourcurrentworkingbranch
Listsbranches;starscurrentbranch
Deletesabranch
BRANCHMANAGEMENTgitbranch*masterfeature1
gitbranch-Dfeature1
MERGINGgitcheckoutmastergitmergeabranch
Mergeschangesinabranchintomaster
FAST-FORWARDMERGEWhencommitshaveonlybeenaddedtoabranch,
justpointtothebranch'scommitobject
master>>Amaster,newbranch>>Amaster>>A<-B<<newbranchA<-B<<master,newbranch
MERGINGCOMPOSITEMERGE
Whenbothbrancheshavechangedandcanbecleanlymerged,
anewcommitobjectiscreated;ithastwoparents.
B(masterwork)↙↖AD(merge)↖↙C(newbranchwork)
CONFLICTSgitmergeabranchAuto-merginghello.txtCONFLICT(content):Mergeconflictinhello.txtAutomaticmergefailed;fixconflictsandthencommittheresult.gitmergetoolgitcommit
Theresultisjustlikeacompositemerge.
TypicalConflictMarkup<<<<<<<HEADLinemodifiedinmaster=======Linemodifiedinabranch>>>>>>>abranch
gitmergeabranch/conflict:youcanhandeditit/gitadd.gitcommit
REBASING
Reconfigurebranchhistorysothatthesamechangesarebasedonadifferentcommit
Reconfiguresabranchsothatwhenmastermergesit,
itisafast-forwardmerge
B↙A⇒A←B←C↖C
gitcheckoutabranchgitrebasemaster
Bringsupanedit-listofcommitstosquashtogether
SQUASHINGWhenyouarealreadyarewithoutconflicts...
gitrebasemaster-i--autofix
Undoesallcommits,butkeepschangesstagedforacommit
Committomasterbranchinonecommit
gitreset--softmastergitcommit-m"abrancheswork,nowinonecommit"
gitcheckoutmastergitmerge--squashabranchgitcommit-m"abranchinonecommit"
COLLABORATINGCloningPullPush
CLONEgitclonehttps://github.com/ncarb/Repo.git
Init+Copiesrepository+addsremotereferences
gitremoteaddmehttps://github.com/davious/Repo.git
Addsaremote
gitfetch
Bringsdownobjectsfromremoterepositoryupdatesremotebranchstoredlocally
Shortcutfordoingafetchand
Setabranchtotrackorigin's
PULLgitpull
Shortcutfordoingafetchandmergingchangesintothebranch
gitpull--rebase
rebasingthebranchtobeafast-forwardoftheremotegitbranch-uorigin/master
masterbranch
Setanewbranchtotrackorigin'smasterbranch
gitcheckout-babranchorigin/master
Pusheslocalcommitstotheremote.
Pushesatagtoaremoterepository
PUSHgitpush[remote]
Iftherehavebeenchangessinceyourlastfetch,yourpushwillbecancelled.
gitremoteset-url--pushoriginhttps://github.com/davious/Repo.git
Changesthedefaultrepositoryyoupushtogitpush-f
Forcetheremotetoacceptout-of-syncchanges.Notusuallydonewhilecollaborating.
gitpushorigin2.0
VISUALSTUDIOINTEGRATIONmsys-gitposh-gitGitHubforWindowsSeeGitVisualStudioGitProvidergit-tfs
MSYS-GITBasicCommand-linesupport
GitBashShell
GitGUI
POSHGITPowershellEnhancedGitCommand-lineExperience
C:\Users\danderson\Dev[master+3~4-0|+0~1-0]>
Fancy,color-codedcommandpromptAuto-completedgitcommandsandargumentsbranchupstream:insync,ahead,behind,both
files:staged,unstaged+=addedfiles
~=modifiedfiles-=deletedfiles
GITHUBFORWINDOWSSimpleGitHubaccountmanagement
Appeye-candyFuntoviewhistoryFuntoviewunifieddiffsEasytosynclocalrepositorieswithGitHubrepositoriesMsys-GitandPosh-Gitarebundledinwithit
SEEGITVisualApplicationforGit
VISUALSTUDIOGITPROVIDERTeamExplorer:ChangedFiles,Commit,Push,Pull,ConflictResolutionSolutionExplorer:FileStatus,HistoryImprovementsforthcomingIntegratedwithTeamFoundationService
Note:SolutionProviderisgitaddagnostic
GIT-TFSPluginforGitcommand-line
gittfsclonehttp://tfs:8080/tfs/DefaultCollection$/Project
gitcheckout-bstorygitcommit-am"Progress"gittfspullgittfsshelve"ShelvesetName"gittfscheckintool
AllowsyoutousegitfordevelopmentwhenrepositoryisTFS
Note:CommitstoTFSasonecommit,evenwhenyouhavecommittedmultipletimes:
noneedtorebase
GITHUBPopularThrivingCommunityGreatCodeWebExperienceOrganizationSupportPullRequestsSophisticatedCodeReviewRepositoryWikiIssueTrackingLowCostWebApiTeamCityintegration
GITHUBINTEGRATIONDEVELOPEREXPERIENCE
trackmainrepositorypullrequestwhenreadyforreviewrequestisverfiedbyTeamCityrequeststartscoderevieweasytocommentdirectlyoncodechangesinGitHubGitHubprovidesemailnotificationsonbuildstatusandcodereviewabilitytopushbranchestoindividualaccounttocollaboratewithteammembers
GITHUBINTEGRATIONREVIEWEREXPERIENCE
PullRequestsarecheckedbyTeamCity;notificationsinpullrequestcommentsEasilyseeifrequestwillmergewithoutconflictsCanuseJohnResig'sNode.jsmodulePulleytorebasepullrequestsandcloseit
CONCLUSIONGitisawell-designedversioncontrolsystem.
MicrosoftsupportsGit.
Weareusinggitlocallywithgit-tfsrightnow.
—
GitHuboffersasophisticatedrepositoryservice.
TeamCitysupportsGitandGitHub.
WecouldbeusingGitHubrightaboutnow.