Your SlideShare is downloading. ×
0
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Git
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Git

878

Published on

Brett Smith's Spring 2011 presentation on Git, the popular open source version control system.

Brett Smith's Spring 2011 presentation on Git, the popular open source version control system.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
878
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
25
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • Version Control – Who has ever made a backup of some source code before making a major change to it? That’s a basic form of version control. You also see version control on Wikipedia, with it’s storage of change history.Modern version control software usually includes the following: * Manages changes * Allows multiple developers to work together on the same project, even the same file * Merge those changes * Track who changed what and when * Maintain multiple lines of development at a timeFast – Git was built by Linus Torvalds (Chief architect of the Linux kernel). Git was built from the ground up with speed in mind, and takes advantage of an intimate knowledge of the Linux kernel to do what it needs to do quickly. This means that Windows performance and support wasn’t very good before Git started gaining a lot popularity.Distributed – Instead of just having the version history on your machine or a server machine, the version history is kept on ALL clients. Calling one particular machine with the history the server is artificial, since it knows just as much as any of the clients do, but it’s often convenient to have your development efforts focus around one central machine.This distribution also makes Git that much faster. You don’t have to use any network operations to request project history or to look at differences between files, because you already have all that information locally. You’ll still be able to make changes when you don’t have access to the Internet and to record those changes in your local database. When you have Internet again, you’ll sync those changes with the other developers.
  • Now I’ll go over some basic terminology in Git that is very important to understand if you want to use Git.Modified – Literally, you have modified a file, but you haven’t interacted with Git on any way with your modification yet.Staged – You inform Git to pay attention to your modification AS IT CURRENTLY IS (Git makes a copy). This is also sometimes referred to as the index.Committed – Git has recorded your modification for the benefit of future generations.
  • Git add is also called “staging the files”Git reset copies files from the latest commit into the stage. This is an “unstage” operation.Git checkout copies files from the stage to your working directory. Use this to throw away modifications to files.
  • All commands in git are “git”, space, followed by a verb.Git init creates a new git repository in the current directory. Nothing is tracked yet.Using .gitignore, git status, and git reset – filesUse git mv to move files, same as mv, git add, git rm. Git is very intelligent about file movement.
  • Git clone clones the ENTIRE repository. That is, a snapshot of each file at each revision. This means that all operations will be lightening fast since they’re all local, but it does have the downside that git clone might take a while with larger repositories.Git pull “pulls” any changes made to the remote repository (the one at the location specified in git clone) into your local repository.Git push pushes any changes committed to the local repository to the remote repository.
  • Git log –pretty = one of oneline, short, medium, full, fuller, email, raw
  • What is a branching? It means you diverge from the main line of development and continue to do work without making any changes to the main line. For example, branches are commonly made for maintenance development from previous releases, so the main line can be devoted to current work with the latest major revisions. Or, you might make a branch for working on a particularly large bug fix. Or, simply an experimental branch to see if a series of changes can improve the software any. If they do, they’re easily merged back in, if it doesn’t, no harm done to the main line.Branching is often hailed as one of Git’s strongest points. It’s so simple, convenient, and elegant and fast to create branches and merge them in again that it’s often referred to as Git’s killer feature.
  • Git does a three way merge here.
  • This is the first commit in a repository, a commit that contains three files. The blobs represent each file, the tree object is the root folder which contains pointers to each file in the folder, and the commit object contains a pointer to the root folder.Git stores file snapshots at each revision, not deltas (diffs). File that change have an entirely new object devoted to the new file. If a file stays the same, the new tree object for the commit points to the same blob.
  • Here is the same repository after two more commits. Each of the blue objects is the new tree object representing the root directory of the commit.
  • Here’s the same repository, but showing the masterbranchSo what happens when we create another branch for the repository?...
  • This is all well and good, but how does Git know what branch or commit we’re currently working with in the working directory? …
  • It turns out that Git has a special pointer to what we’re currently working withSo what happens if we switch to the testing branch and make a commit?
  • So what happens if we switch back to the master branch, change some files, and commit?
  • Bisect lets you perform a binary search across commits, searching for the origin of a particular bug
  • Transcript

    • 1. Git<br />From noob to pro<br />
    • 2. Version Control<br />Fast<br />Distributed<br />What is Git?<br />
    • 3. “Git made me a more productive coder because it showed me how much progress I had made” – Thomas “Synk” Kelley<br />“I use Git because the commands are really easy to use. I use Git because if I want to set up a Git server on the Internet it does not require any extra processes on my server, all I need is an SSH connection” – Chris “Panda” Nord<br />Why Git?<br />
    • 4. Modified – I modified a file<br />Staged – Git has taken a snapshot of my modification<br />Commited – Git has permanently recorded my modifications from the stage<br />The three file stages in Git<br />
    • 5. The three file stages in Git<br />
    • 6. git init<br />git add files<br />git commit –m ‘my commit message’<br />A new Git repository<br />
    • 7. ..What just happened?<br />
    • 8. ..What just happened?<br />
    • 9. git clone location<br />git clone myserver.com:/path/to/repo/.git<br />gitclone git://github.com/username/project.git<br />git pull<br />git push<br />An existing repository<br />
    • 10. gitdiff<br />git revert<br />git checkout<br />git log<br />git blame<br />git tag<br />Useful commands<br />
    • 11. git branch new_branch<br />git checkout new_branch<br />Branching<br />
    • 12. Branching<br />
    • 13. Merging<br />
    • 14. Merging<br />
    • 15. Implementation detail<br />
    • 16. Implementation detail<br />
    • 17. Implementation detail<br />
    • 18. Implementation detail<br />
    • 19. Implementation detail<br />
    • 20. Implementation detail<br />
    • 21. Implementation detail<br />
    • 22. Interactive staging<br />Stashing<br />Bisect<br />Other notables!<br />
    • 23. Questions?<br />
    • 24. Images taken from progit.org and marklodato.github.com/visual-git-guide<br />Credits<br />

    ×