Introduction to:               &Max Claus Nunesmaxcnunes@gmail.comhttp://blog.maxcnunes.nethttps://github.com/maxcnunes
Version Control Systems•   Without•   Local•   Centralized         What?!•   Distributed
Without Version Control            Systems• Copy files into another directory• Store or Share files backups by email• Stor...
Local Version Control              Systems• Just a local  Database• Systems:  – RCS - Revision    Control System    (Today...
Centralized Version Control           Systems• A Central Server• The most used for  the companies• Systems:  – CVS  – Subv...
Centralized Version Control            SystemsAdvantages• Everyone knows to a certain degree what everyone else on the pro...
Distributed Version Control           Systems• Distributed: each client  has fully mirror of the  repository• Systems:  – ...
Distributed Version Control            SystemsAdvantages• Everytime someone pulls from the central repository, Git gets a ...
A Short History of Git• (1991-2002) – The Linux kernel changes to the  software were passed around as patches and  archive...
Some Git Goals• Speed• Simple design• Strong support for non-linear development  (thousands of parallel branches)• Fully d...
Git Basics•   Snapshots, Not Differences•   Nearly Every Operation Is Local•   Git Has Integrity•   Git Generally Only Add...
Snapshots, Not Differences                         http://git-scm.com           Differences
Snapshots, Not Differences                       http://git-scm.com           Snapshots
Nearly Every Operation Is             Local• You can work offline as look the history,  commit some changes or create bran...
Git Has Integrity• Git generate a SHA-1 hash for each commit  associated a file• Git realize a checksum everytime is tried...
Git Generally Only Adds Data• Doing commits regularly it is very difficult to  get the system to do anything that is not  ...
The Three States                              http://git-scm.comModified/Untracked   Staged   Committed
Lets start use Git
So, what are we going to do?• Configure             •   Alias• Create a Repository •     Diff• Passing through the 3 •   T...
Configure• Download and Install Git: http://git-scm.com/• You just need the Git Bash to work
Usernamegit config --global user.name "Your Name Here"# Sets the default name for git to use when you commitEmailgit confi...
Create a Repository     Access your project directory    cd your_folder_name    Create the repository    git init    Check...
Passing through the 3 States                                  How is the status now? Create or Change a file/folder       ...
Adding, Removing and RenamingStages Allgit add -AStages new and modified, without deletedgit add .Stages modified and dele...
.gitignoreIs a hidden file named .gitignore on your root’s repository that contains a listof all ignored files and folders...
DiffCompare the working directory with local repositorygit diff HEAD file_nameCompare the working directory with staging a...
Custom AliasCreate a new alias to show a log with graphgit config --global --add alias.lol "log --graph --decorate --prett...
BranchsCreate and Switch for a new branchgit checkout –b branch_nameList all local branchsgit branchSwitch for a existing ...
MergesMerge on the current branch changes made on another branchgit merge branch_name         Before merge         After m...
Merge Conflicts                     Master              DevelopmentMerge conflict                        Resolving the con...
TagsList all tagsgit tagCreating an annotated taggit tag -a tag_name -m message descriptiongit tag -a v1.0 -m my version 1...
Git + Social Coding
Add and Pull a Remote             RepositoryCloning a or repositorygit clone git@github.com:owner_repo/repo_name.gitActual...
Pushing to the Remote             RepositoryPushing for the remote repositorygit push remote_name branch_namegit push orig...
BasicWorkflow           http://nakedstartup.com/2010/04/simple-daily-git-workflow
Others helpful (or not) commands List of Git Contributors git shortlog -s -n Show the SHA1 of a file staged git ls-files -...
Others helpful (or not) commands Undo git add before commit git reset HEAD file_name One line logs git log --pretty=onelin...
Questions
Look more…• Using SSH security connections• Git Cheat Sheet Grey• http://git-scm.com
Introduction to Git and Github
Introduction to Git and Github
Introduction to Git and Github
Introduction to Git and Github
Introduction to Git and Github
Introduction to Git and Github
Introduction to Git and Github
Upcoming SlideShare
Loading in...5
×

Introduction to Git and Github

1,114

Published on

This is a short presentation about git and github. This document describes some good points to work with git and the common commands used on git.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,114
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
30
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Introduction to Git and Github

  1. 1. Introduction to: &Max Claus Nunesmaxcnunes@gmail.comhttp://blog.maxcnunes.nethttps://github.com/maxcnunes
  2. 2. Version Control Systems• Without• Local• Centralized What?!• Distributed
  3. 3. Without Version Control Systems• Copy files into another directory• Store or Share files backups by email• Store or Share files by pendrive
  4. 4. Local Version Control Systems• Just a local Database• Systems: – RCS - Revision Control System (Today is centralized) http://git-scm.com
  5. 5. Centralized Version Control Systems• A Central Server• The most used for the companies• Systems: – CVS – Subversion – TFS http://git-scm.com
  6. 6. Centralized Version Control SystemsAdvantages• Everyone knows to a certain degree what everyone else on the project is doing• Administrators have more control over what everyone can doDisadvantages• If Server goes down, this means nobody can save changes• If HD Server breaks, this means good bye all control version history
  7. 7. Distributed Version Control Systems• Distributed: each client has fully mirror of the repository• Systems: – Git – Mercurial – Bazaar http://git-scm.com
  8. 8. Distributed Version Control SystemsAdvantages• Everytime someone pulls from the central repository, Git gets a full history of the changes• Most of the functionalities doesn’t need access to some network. So we can work even not connected to the internet• A project can be associated to a more than one remote repository• You can do anything just using the consoleDisadvantages• Git requires some learning curve to understand its concept• The administrators don’t have control over what happens on each client local repository
  9. 9. A Short History of Git• (1991-2002) – The Linux kernel changes to the software were passed around as patches and archived files.• (2002) – The Linux kernel project began using a proprietary DVCS system called BitKeeper.• (2005) – The relationship between Linux kernel and the BitKeeper broke down. After that Linux development community create their own tool named Git, based on what they learned using the BitKeeper.
  10. 10. Some Git Goals• 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)
  11. 11. Git Basics• Snapshots, Not Differences• Nearly Every Operation Is Local• Git Has Integrity• Git Generally Only Adds Data• The Three States
  12. 12. Snapshots, Not Differences http://git-scm.com Differences
  13. 13. Snapshots, Not Differences http://git-scm.com Snapshots
  14. 14. Nearly Every Operation Is Local• You can work offline as look the history, commit some changes or create branchs
  15. 15. Git Has Integrity• Git generate a SHA-1 hash for each commit associated a file• Git realize a checksum everytime is tried to store some change. So Git knows when something was changed or the file is corrupted 24b9da6552252987aa493b52f8696cd6d3b00373
  16. 16. Git Generally Only Adds Data• Doing commits regularly it is very difficult to get the system to do anything that is not undoable or lose some change• Let us more comfortable to experiment changes, because is easy to recover a previous version
  17. 17. The Three States http://git-scm.comModified/Untracked Staged Committed
  18. 18. Lets start use Git
  19. 19. So, what are we going to do?• Configure • Alias• Create a Repository • Diff• Passing through the 3 • Tag States • Ignoring Files and• Branch Folders• Merge • Getting a Remote• Log Repository • Basic Workflow
  20. 20. Configure• Download and Install Git: http://git-scm.com/• You just need the Git Bash to work
  21. 21. Usernamegit config --global user.name "Your Name Here"# Sets the default name for git to use when you commitEmailgit config --global user.email "your_email@example.com"# Sets the default email for git to use when you commit
  22. 22. Create a Repository Access your project directory cd your_folder_name Create the repository git init Check the repository current status git statusAll your repository data and configuration is stored on a hidden folder named .git on your repository’s root
  23. 23. Passing through the 3 States How is the status now? Create or Change a file/folder From Nowhere/Repository Working Directorytouch file_name/folder How is the status now? Add objects to staging area Working Directory  Staging Areagit add (general_comand/file_name/folder_name/…) How is the status now? Staging Area  Repository Save objects on local repositorygit commit –m ‘This is my awesome comment’ How is the status now?
  24. 24. Adding, Removing and RenamingStages Allgit add -AStages new and modified, without deletedgit add .Stages modified and deleted, without newgit add -uStages a removed file git rm file_name/Stages a removed folder git rm -r folder_name/Stages a renamed file git mv old_file_name new_file_name
  25. 25. .gitignoreIs a hidden file named .gitignore on your root’s repository that contains a listof all ignored files and folders, like:*.tmpx64/
  26. 26. DiffCompare the working directory with local repositorygit diff HEAD file_nameCompare the working directory with staging areagit diff file_nameCompare the index with local repositorygit diff --cached file_name Compare the branchs showing just the status and file name git diff --name-status branch_1 branch_2
  27. 27. Custom AliasCreate a new alias to show a log with graphgit config --global --add alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit --all"Using the new aliasgit lolList all the local configurationsgit config –-local -l
  28. 28. BranchsCreate and Switch for a new branchgit checkout –b branch_nameList all local branchsgit branchSwitch for a existing branchgit checkout branch_name Working with Remote RepositoriesAdd a local branch for a remote repositorygit push remote_name branch_nameUpdate local branch from a remote branchgit pull remote_name branch_name
  29. 29. MergesMerge on the current branch changes made on another branchgit merge branch_name Before merge After merge
  30. 30. Merge Conflicts Master DevelopmentMerge conflict Resolving the conflict Commit the file after resolve the conflict git commit –a -m ‘Resolving merge conflicts’
  31. 31. TagsList all tagsgit tagCreating an annotated taggit tag -a tag_name -m message descriptiongit tag -a v1.0 -m my version 1.0 Working with Remote RepositoriesSharing tagsgit push origin v1.0All tagsgit push origin --tags
  32. 32. Git + Social Coding
  33. 33. Add and Pull a Remote RepositoryCloning a or repositorygit clone git@github.com:owner_repo/repo_name.gitActually what the clone command does is: remote add + pullgit remote add origingit@github.com:owner_repo/repo_name.gitgit pull origin masterAnd actually what the default pull command does is: fetch + mergeUpdate local repository avoiding the amount of merges (fetch+rebase)git pull --rebase repo_name branch_name
  34. 34. Pushing to the Remote RepositoryPushing for the remote repositorygit push remote_name branch_namegit push origin master
  35. 35. BasicWorkflow http://nakedstartup.com/2010/04/simple-daily-git-workflow
  36. 36. Others helpful (or not) commands List of Git Contributors git shortlog -s -n Show the SHA1 of a file staged git ls-files -s file_name Show the SHA1 of a file modified git hash-object file_name Discard changes of a file git checkout --file_name
  37. 37. Others helpful (or not) commands Undo git add before commit git reset HEAD file_name One line logs git log --pretty=oneline Short status git status -s Delete the last commit before Push git reset --hard HEAD~1
  38. 38. Questions
  39. 39. Look more…• Using SSH security connections• Git Cheat Sheet Grey• http://git-scm.com
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×