Git GitHub
Git GitHub
an opinionated discussion
Shreyas
some slides adopted from and inspired by Scott Schacon’s
Grad Student, MIMS’14 seekshreyas
https://github.com/schacon/git-presentations
We’ve all been here ...
We’ve all been here ...
We’ve all been here ...
Problems
• multiple versions
conflicts
• many contributors
• ...
git + Github
a better workflow
git
• Performing a diff
• Committing changes
• Merging branches
More Advantages
tp://bit.ly/git-advantages http://bit.ly/git-linus-intro
.. and
• No .svn directories
• Independence
installing git
http://git-scm.com/downloads
getting setup ...
• Committing
• Branching/Merging
• InspectionCloning a
RepoUpdating
lets dive in..
http://git-scm.com/docs
• Committing
• Branching/Merging
• Inspection
• Cloning a Repo
• Updating
Git Commands
• Creating New
Repo $ git init
• Committing $ mkdir workspace
• Branching/ $ cd workspace
Merging $ ls -al
Initialized empty Git repository in
$ git init
• Inspection ../workspace/.git/
drwxr-xr-x 10 Shreyas staff 340 Jan 15
$ ls -al
17:22 .git
• Cloning a Repo
• Updating
Git Commands
$ cd .git
• Creating New $ tree -a
Repo
• Committing
• Branching/
Merging
• Inspection
• Cloning a Repo
• Updating
Git Commands
$ cd ..
$ touch testfile.md
• Creating New
Repo
• Committing
$ git status
• Branching/
Merging
branch
• Inspection name
staging
• Cloning a Repo area
• Updating
Git Commands
• Creating New
$ git add
Repo
<filename>
$ git status
• Committing
• Branching/
Merging
• Inspection staging
area
• Cloning a Repo
• Updating
Git Commands
• Creating New
Repo $ git commit
$ git status
• Committing
your commit
• Branching/
msg
Merging
• Inspection
• Cloning a Repo
• Updating
Git Commands
• Creating New
Repo $ git reset
(undo add)
• Committing
• Inspection
• Branching/
Merging
HEAD~3
Rewind the branch to get rid of last three
commits
• Updating
$ git mv <filename>
Merging
• Updating
Git Commands
• Creating New
Repo $ git branch list of
branches
• Committing
$ git branch
new branch
<branchname>
Branching/
$ git checkout
•
Merging
switch
• Inspection
<branchname>
• Cloning a Repo
• Updating
Git Commands
• Creating New
Repo branch list
new branch
• Committing dev
• Branching/ switch
Merging branch
• Inspection
• Cloning a Repo
• Updating
Git Commands
• Creating New
$ git merge merge
<branchname>
Repo branches
• Committing
• Branching/
Merging
• Inspection
branch merge
• Cloning a Repo
• Updating
Git Commands
• Creating New
Repo
$ git log
• Committing
--graph text-based graph :)
• Branching/
--decorate
Merging
--abbrev-
• Inspection commit
• Cloning a Repo --all
• Updating --pretty=oneline
Git Commands
• Creating New
Repo
~/.gitconfig
• Committing
[alias]
• Branching/
l = log --pretty=oneline -n 20 --
Merging graph
• Inspection
• Cloning a Repo
• Updating
Git Commands
• Creating New
Repo
$ gitk
• Committing
• Branching/
Merging
• Inspection
• Cloning a Repo
• Updating
Working with others...
• Creating New
Repo
github
• Committing
• Branching/
Merging
• Inspection
• Cloning a Repo
• Updating
GitHub
• Creating New
Repo
create an account
www.github.com/edu
• Committing
• Branching/
Merging
• Inspection
• Cloning a Repo
• Updating
GitHub
• Creating New
Repo
add ssh key
www.github.com/edu
• Committing
• Branching/
Merging
• Inspection
• Cloning a Repo
• Updating
GitHub
• Creating New
Repo
$ git clone <url>
• Committing <name>https://github.com/jblomo/
datamining290
• Branching/
Merging
• Inspection
• Cloning a Repo
• Updating
GitHub
• Creating New
Repo
Fork a repo
• Committing
• Branching/
Merging
• Inspection
• Cloning a Repo
• Updating
GitHub
• Creating New
Repo
$ git pull = git fetch + git merge
• Inspection
• Cloning a Repo
• Updating
GitHub
• Creating New
Repo
GitHub Pull Request
• Committing
• Branching/
Merging
• Inspection
• Cloning a Repo
• Updating
GitHub Ninja Features