Git GitHub

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 40

Workflow

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

git is an open source, distributed


version control system designed
for speed and efficiency
git

git is an open source, distributed


version control system designed
for speed and efficiency
git

git is an open source, distributed


version control system designed
for speed and efficiency
git

git is an open source, distributed


version control system designed
for speed and efficiency

(almost) everything is local


No Network needed for

• Performing a diff

• Viewing file history

• Committing changes

• Merging branches

• Obtaining any other revision of a file

• Switching branches
(almost) everything is local
git

git is an open source, distributed


version control system designed
for speed and efficiency

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 ...

$ git config --global user.name “<YOUR_NAME>”

$ git config --global user.email “<YOUR_EMAIL>”

or edit them in ~/.gitconfig


lets dive in..
gitref.org/

• Creating New Repo

• Committing

• Branching/Merging

• InspectionCloning a
RepoUpdating
lets dive in..
http://git-scm.com/docs

• Creating New Repo

• 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

• Committing $ git status


• Branching/Merging

• 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)

$ git reset --hard HEAD~3


• Branching/Merging

• Updating
Rewind the branch to get rid of last three commits

• Inspection

• Cloning A Repo learn more here : http://git-scm.com/docs/git-reset

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

$ git checkout <branchname>


• Inspection
switch
• Cloning a Repo

• 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

Markdown for documentation

Pages for project hosting

Gist for project hosting

Service Hooks ‘do something’ on commit


may the Force be with you

You might also like