GIT & github

SHARE YOUR CODE

Why should I use version control?


Why should I use version control?


Have you ever:

  • Made a change to code, realized it was a mistake and wanted to revert back?
  • Lost code or had a backup that was too old?
  • Had to maintain multiple versions of a product?
  • Wanted to see the difference between two (or more) versions of your code?
  • Wanted to prove that a particular change broke or fixed a piece of code?

Why should I use version control?


Have you ever:

  • Wanted to review the history of some code?
  • Wanted to submit a change to someone else's code?
  • Wanted to share your code, or let other people work on your code?
  • Wanted to see how much work is being done, and where, when and by whom?
  • Wanted to experiment with a new feature without interfering with working code?

Why git?


  • Speed
  • Simple design
  • Strong support for non-linear development (thousands of parallel branches)
  • Fully distributed
  • Able to handle large projects like the Linux kernel efficiently (speed and data size)

why github?





A social network for programmers :)

history of git


Git basics

Snapshots, Not Differences

git basics

Nearly Every Operation Is Local

You have the entire history of the project right there on your local disk


Git Has Integrity

Everything in Git is check-summed 


Git Generally Only Adds Data

it is very difficult to lose data

git basics

The Three States

Getting Started

config git


git config {key} {value}
user.name
user.email
core.editor
merge.tool

git config --list

Getting Started

Help

git help <verb>

git help config

Auto-Completion

https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
source ~/.git-completion.bash

Setting Up a Git Repository

$ git init
$ git init --bare <directory>

$ git clone git://github.com/schacon/simplegit-progit.git

Setting Up a Git Repository

svn vs git


Setting Up a Git Repository

$ git add *.py
$ git add README

$ git commit -m 'initial project version'

Setting Up a Git Repository

Setting Up a Git Repository

inspecting a git repository

$ git status 

Git Tutorial: git status

$ git log 

inspecting a Git Repository

inspecting a Git Repository

$ git blame <file>

http://www.linuxhispano.net/tira/blame.png

other useful commands


$ cat .gitignore
$ git diff
$ git diff --staged
$ git rm <file>
$ git rm --cached <file>
$ git mv <file_from> <file_to>

Undoing Things


$ git commit --amend

$ git reset 

$ git checkout <commit> <file>
$ git checkout <branch>

git revert <commit>

git clean 

undoing things

reset vs revert

Git Tutorial: Revert vs Reset

Don’t Reset Public History

Git Branches

Git Tutorial: Branching and Merging

git branches

$ git branch <branch>
Git Tutorial: Create new branch     Git Tutorial: git branch

git branches

$ git checkout <branch>

Git Tutorial: Switch between multiple features in a single repo with git checkout.      Git Tutorial: Attached vs Detached Head

git branches

$ git merge 
$ git merge --no-ff 

fast-forward 3-way merge

Git Tutorial: Fast-forward merge       Git Tutorial: Three way merge

Resolving Conflicts

http://www.linuxhispano.net/tira/conflictos.png
$ git merge some_branch
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.

Working with Remotes


$ git remote
$ git remote add test http://dev.example.com/test.git 


$ git fetch <remote> <branch>
$ git branch -r
$ git merge origin/master

 git pull <remote> <branch>

git push <remote> <branch>

Git Work-flows

getting stated with github


https://help.github.com/articles/set-up-git


https://help.github.com/articles/generating-ssh-keys

useful links and references

http://git-scm.com/book/

https://www.atlassian.com/git/tutorial

http://try.github.io

http://zrusin.blogspot.com/2007/09/git-cheat-sheet.html

http://www.vogella.com/articles/Git/article.html

http://marklodato.github.io/visual-git-guide/index-en.html

http://gitimmersion.com

http://www.youtube.com/GitHubGuides

http://sixrevisions.com/resources/git-tutorials-beginners/




Gracias


@rafa_laverde

Made with Slides.com