Git Presentation - Handout

258 views

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
258
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Git Presentation - Handout

  1. 1. Internals Usage Distribution Merging and Rebasing ExtrasGit for mere mortalshttps://github.com/Kelsin/git-presentationChristopher GiroirJuly 26th, 2011Christopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing Extras1 InternalsObjectsBranches and Tags2 UsageCreating and CommitingInspection3 DistributionAdvantagesArchitectureCommand Examples4 Merging and RebasingMergingRebase5 ExtrasRemotesMiscChristopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasObjectsObject StoreThe git object store is a big black box and we like it that way.It was written for speed and correctnessComparisonsMore information than CVSMore sane than SVNMore efficient than MercurialChristopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasObjectsBlobs_^]XYZ[BlobBlobs store file data (text or binary).Labeled by SHA1. If the content changes, so does the SHA.Christopher Giroir Git for mere mortals
  2. 2. Internals Usage Distribution Merging and Rebasing ExtrasObjectsTrees_^]XYZ[Blob_^]XYZ[Tree //??_^]XYZ[BlobTrees point to blobsRepresent the entire state of the working directoryAlso labeled by SHA’s.Christopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasObjectsCommitsonmlhijkCommit _^]XYZ[BlobonmlhijkCommitOO//_^]XYZ[TreeCC§§§§§§§§§§§§§//_^]XYZ[BlobPoints to a tree object and parent commit(s)Stores author and date informationLabeled by SHA’s.Christopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasObjectsImportant Distinction!Commits link to entires TREES not DIFFS.Diffs are not stored in git, they are computed.Christopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasBranches and TagsPointersMost other things in git are pointers to commits.?>=<89:;a //v3.0.1?>=<89:;b //bbbbbbbbbMaster?=89:;c //?=89:;d //?=89:;eSAVE-465?=89:;g //origin/SAVE-576?=89:;h //?=89:;iSAVE-576Branches are just labels to commit SHA’sTags are just labels with meta informationChristopher Giroir Git for mere mortals
  3. 3. Internals Usage Distribution Merging and Rebasing ExtrasBranches and TagsRewriting HistoryRewriting a commit changes it’s SHAAny commit after it changes as wellMost branch operations are quick and painlessCan shoot yourself in the foot and heal it back up againChristopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasCreating and CommitingStarting OutSetting User Infogit config --global user.name Christopher Giroirgit config --global user.email kelsin@valefor.comCompletely New Repocd dir-with-codegit initCloning any accessible repogit clone git@github.com:Kelsin/configs.gitcd configsChristopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasCreating and CommitingCommitsInitial Commitgit add .git commit -m Initial CommitEditing some filesgit add edited-file.rbgit commit -m Improved everythingAdding to previous commitgit add edited-file.rbgit commit --amendChristopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasInspectionStatus and DiffsNormal Statusgit statusWhat’s current changed?git diffChanges from only one filegit diff example-file.rbChanges between branchesgit diff masterChristopher Giroir Git for mere mortals
  4. 4. Internals Usage Distribution Merging and Rebasing ExtrasInspectionShow and LogShow current commitgit showShow some other commitgit show 234ab32Show log of recent commitsgit logShow pretty loggit log --graph --decorate --onelineChristopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasInspectionRefs and ObjectsBy commit idgit show 234ab32By branchgit show masterBy taggit show v3.0.2Relativegit show HEAD^Christopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasAdvantagesDistributed Source ControlOnly difference from remote and local (normally): workingdirectoriesCan function offlineCan “push” and “pull” from each other, as well as serversEach of our computers serves as a backup of the serverChristopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasArchitectureLocation DescriptionsGit has 4 locations where commits are storedRemote Repo Any remote object storeLocal Repo You local object storeIndex A single spot to “stage” commitsWorking Directory These are the files you are editingChristopher Giroir Git for mere mortals
  5. 5. Internals Usage Distribution Merging and Rebasing ExtrasCommand ExamplesLocations and CommandsWorkinggit addIndexgit commitLocal Repogit push##git checkoutggRemote Repogit fetchccBC@Agit pullOOChristopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasMergingFast Forward Merginggit checkout mastergit merge SAVE-234?=89:;a //?=89:;b //?=89:;c //?=89:;d //?=89:;eMasterSAVE-234Christopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasMergingMerginggit checkout mastergit merge SAVE-234?=89:;a //?=89:;b //aaaaaaaaa?=89:;c //?=89:;d //?=89:;e //?=89:;76540123jMaster?=89:;g //?=89:;h //?=89:;i@@¢¢¢¢¢¢¢¢¢SAVE-234Christopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasMergingNo Fast Forward Merginggit checkout mastergit merge --no-ff SAVE-234?=89:;a //?=89:;bbbbbbbbbb//?=89:;76540123fMaster?=89:;c //?=89:;d //?=89:;e@@         SAVE-234Christopher Giroir Git for mere mortals
  6. 6. Internals Usage Distribution Merging and Rebasing ExtrasRebaseRebasegit checkout SAVE-234git rebase master?=89:;a //?=89:;b //?=89:;c //?=89:;d //?=89:;ewwoooooooooooooooooMasterGFED@ABC?=89:;g //GFED@ABC?=89:;h //ONMLHIJKGFED@ABCiSAVE-234Christopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasRemotesRemote CommandsAdding remotegit remote add origingit@github.com:Kelsin/configs.gitFetch all remote objectsgit fetchShow all branchesgit branch -aChristopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasRemotesPushingPush objects from source to destinationgit push origin source:destinationRemoving remote branchgit push origin :destinationSetting upstreamgit push -u origin SAVE-453Force pushesgit push -f origin SAVE-453Christopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasRemotesPullingPull in remote changesgit pull origin masterSpecial caseExecutes:git fetchgit mergeMerges in to your current branchChristopher Giroir Git for mere mortals
  7. 7. Internals Usage Distribution Merging and Rebasing ExtrasMiscGit Config FileMy git config is available athttps://github.com/Kelsin/configs/blob/master/.gitconfigPush defaultsCommiter name and emailColor settingsAliasesChristopher Giroir Git for mere mortalsInternals Usage Distribution Merging and Rebasing ExtrasMiscSome TipsAlways work on branchesWhen in doubt use GitX or gitk to see what you are doingWhen in doubt save a new branch so you can always get backAdd the current git branch into your promptExplore with rebase and cleaning up code before final pushChristopher Giroir Git for mere mortals

×