Git GitHub
Git GitHub
Git GitHub
an opinionated discussion
Shreyas
Grad Student, MIMS’14 seekshreyas some slides adopted from and inspired by Scott Schacon’s 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
• Switching branches
(almost) everything is local
git
More Advantages
http://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/Merging
$ cd workspace
• Inspection $ ls -al
$ git init Initialized empty Git repository in ../workspace/.git/
• Cloning a Repo
$ ls -al drwxr-xr-x 10 Shreyas staff 340 Jan 15 17:22 .git
• Updating
Git Commands
$ cd .git
• Creating New Repo $ tree -a
• Committing
• Branching/Merging
• Inspection
• Cloning a Repo
• Updating
Git Commands
$ cd ..
$ touch testfile.md
• Creating New Repo
• Inspection
branch name
• Cloning a Repo
staging area
• Updating
Git Commands
• Creating New Repo
$ git add <filename>
• Committing $ git status
• Branching/Merging
• Inspection
• Cloning a Repo
staging area
• Updating
Git Commands
• Creating New Repo
$ git commit
• Committing $ git status
• Branching/Merging
your commit msg
• Inspection
• Cloning a Repo
• Updating
Git Commands
• Creating New Repo
$ git reset
• Committing (undo add)
• Branching/Merging
changes staged
• Inspection
• Cloning a Repo
• Updating
changes unstaged
Git Commands
• Creating New Repo
$ git reset --soft HEAD^
• Committing (undo a commit and redo)
• Updating
Rewind the branch to get rid of last three commits
• Inspection
also refer
git revert : http://git-scm.com/docs/git-revert.ht
ml
git stash : http://git-scm.com/docs/git-stash
Git Commands
• Creating New Repo
$ git rm <filename> remove a file from the
• Committing repo
as expected, you will need to commit the change
• Branching/Merging
• Inspection
$ git mv <filename>
• Cloning a Repo move/rename a file from the repo
as expected, you will need to commit the change
• Updating
Git Commands
• Creating New Repo
$ git branch list of branches
• Committing
• Branching/Merging
$ git branch <branchname> new branch
• Updating
Git Commands
• Creating New Repo
branch list
• Committing new branch dev
• Branching/Merging
switch branch
• Inspection
• Cloning a Repo
• Updating
Git Commands
• Creating New Repo
$ git merge <branchname> merge branches
• Committing
• Branching/Merging
• Inspection
• Cloning a Repo
branch merge
• Updating
Git Commands
• Creating New Repo $ git log
• Committing --graph text-based graph :)
• Branching/Merging --decorate
• Inspection --abbrev-commit
• Cloning a Repo --all
• Updating --pretty=oneline
Git Commands
• Creating New Repo ~/.gitconfig
• Committing [alias]
• Branching/Merging l = log --pretty=oneline -n 20 --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
• Committing www.github.com/edu
• Branching/Merging
• Inspection
• Cloning a Repo
• Updating
GitHub
• Creating New Repo add ssh key
• Committing www.github.com/edu
• Branching/Merging
• Inspection
• Cloning a Repo
• Updating
GitHub
• Creating New Repo $ git clone <url> <name>
• Committing
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
$ git push
• Committing
• Branching/Merging
• Inspection
• Cloning a Repo
• Updating
GitHub
• Creating New Repo GitHub Pull Request
• Committing
• Branching/Merging
• Inspection
• Cloning a Repo
• Updating
GitHub Ninja Features