1 / 11

Introduction to git

Introduction to git. version control for serious hackers ;). Alan Orth Nairobi, Kenya September, 2010. The Problem. - One project, many developers... - Who fixed (or broke) what? - Exactly which changes fixed (or broke) feature X?

artie
Download Presentation

Introduction to git

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to git version control for serious hackers ;) Alan Orth Nairobi, Kenya September, 2010

  2. The Problem - One project, many developers... - Who fixed (or broke) what? - Exactly which changes fixed (or broke) feature X? - How can we undo those changes easily (and log them, so that we don't forget!)

  3. The Solution - Version control! - Many solutions over the years... - CVS (kitambo) - Subversion (was very popular until git) - Mercurial - Bazaar - I am biased, but git is the $%^!. - Written by Linus Torvalds (… heard of Linux?)

  4. git practice $ mkdir test $ cd test $ git init . $ git status 1. Create a new directory 2. Move inside the new directory 3. Initialize the new directory as a git repository 4. Show the current status of the repository

  5. git practice $ gedit hello.txt Type “Hello World” then save and exit $ git status git shows hello.txt as “untracked” Untracked files are files which are in the current directory but are not under version control!

  6. git practice $ git add hello.txt $ git commit -m “Add hello.txt” $ git status $ git log 1. Add hello.txt to version control 2. Commit changes in current repository (-m tells git to save a “commit message” with this commit) 3. Show status of repository 4. Show the commit log (a sort of history)

  7. git configuration Bio Sprint?! “Ammend” the last commit, telling git who you are: $ git commit --ammend --author=”Alan Orth <aorth@cgiar.org>” Make the settings permanent: $ git config --global user.name “Alan Orth” $ git config --global user.email a.orth@cgiar.org

  8. Branching and merging - master: the main “branch” of development - Branches allow you to develop features and fix bugs without polluting (or destabilizing) the master - Many paradigms, but in git: branch early, branch often! - Crazy idea you want to try? Make a branch! If something breaks, just delete the branch :) - Otherwise, “merge” the branch back into master...

  9. Branching and merging $ git branch goodbye $ git checkout goodbye $ git status 1. Create a new branch called “goodbye” 2. Switch to the new branch 3. Print out the status of the repository on the current branch. Note the [goodbye ] in the top left... we are on the “goodbye” branch!

  10. Branching and merging $ gedit goodbye.txt $ git add goodbye.txt $ git commit -m “Add goodbye.txt” $ git checkout master $ git merge goodbye 1. Put text in goodbye.txt and then save and exit 2. Add goodbye.txt to version control 3. Commit changes to the current repository 4. Switch back to the master branch 5. “Merge” the changes from the “goodbye” branch into the current branch.

  11. Getting Help - Don't RTFM, it is confusing and technical - Use google instead... there is always someone else who has already tried to do what you're trying to do! - Use git status frequently to see what's up - Use git diff to see what changes have been made - Use git branch to list branches in your repo - Pro git: http://progit.org/ A great, free ebook - Ask Alan?

More Related