Lec04 Git
Lec04 Git
CS 3251
Intermediate Software Design
Prof. Graham Hemingway
Basic Intro to Git
We will:
• Discuss the basic Git model
• Pull/clone les from a repository on GitHub
• Edit les in your own local Git repo
• Push les to a repo on GitHub
fi
fi
fi
Register Your GitHub Account
Go to:
• https://vanderbilt.rosterlink.org
• On right side click “Link GitHub Account”
• You should get an email asking you to join
the course GitHub organization - accept it
Git History
• Linux development community
• Initial goals:
• Speed
• Support for non-linear development (thousands of
parallel branches)
• Fully distributed
• Able to handle large projects like Linux e ciently
ffi
Git Resources
• At the command line: (where verb = con g, add, commit, etc.)
$ man git-<verb>
(Git, Mercurial)
Result: Many operations are local
Git Takes Snapshots
Subversion
Git
Git uses checksums
• In Subversion each modi cation to the central repo incremented
the version # of the overall repo.
• How will this numbering scheme work when each user has their
own copy of the repo, and commits changes to their local copy
of the repo before pushing to the central server?
Note: working directory sometimes called the “working tree”, staging area sometimes called the “index”.
Git le lifecycle
fi
Basic Work ow
Basic Git work ow:
• You can call git con g –list to verify these are set.
• These will be set globally for all Git projects you work with.
• You can also set variables on a project-only basis by not using the
--global ag.
2. You can also set the editor that is used for writing commit
messages:
$ git config --global core.editor nano (it is vim by default)
fl
fi
Create a local copy of a repo
Two common scenarios: (only do one of these):
A) To clone an already existing repo to your current directory:
$ git clone <url> [local dir name]
This will create a directory named local dir name, containing a
working copy of the les from the repo, and a .git directory
(used to hold the staging area and your actual repo)
This takes a snapshot of these les at this point in time and adds it
to the staging area.
$ git diff