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?
- It's widely in use
- Social networking functionality
- Pastebin-style site called Gist
- Is a community
- Octocat octodex.github.com
- github pages pages.github.com

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.bashsource ~/.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 log
inspecting a Git Repository
inspecting a Git Repository
$ git blame <file>

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
Don’t Reset Public History
Git Branches

git branches
$ git branch <branch>


git branches
$ git checkout <branch>
git branches
$ git merge
$ git merge --no-ff
fast-forward 3-way merge
fast-forward 3-way merge

Resolving Conflicts

$ 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
useful links and references
https://www.atlassian.com/git/tutorial
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
Gracias
git & github
By Rafael Laverde
git & github
- 2,357