SlideShare a Scribd company logo
Intro to Git
presented by Brian K. Vagnini
Hosted by
What is version control?
Local Version Control
Centralized Version Control
Distributed Version Control
What is Git
Software that stores a snapshot of your files
Everything is local to your machine
Does a SHA-1 checksum and stores that for each snapshot
Three stages
Modified
Staged
Committed
Three sections of a git project
Working directory
Staging area
git repo
Installing git
Linux - yum install git-core (or apt-get install git-core)
Mac - using macports, sudo port install git-core
or browse to git-scm.com/download/mac
Windows - msysgit.github.com
post install
git config --global user.name ‘Your Name’
git config --global user.email youremail@domain.com
Getting help
Google
Offline:
git help <verb>
git <verb> --help
man git <verb>
Getting started
1- Existing folder with files and no version control
git init
git add .
git commit -m “Your message here”
2- Nothing at all- Cloning an existing repo
git clone https://github.com/vinta/awesome-python.git
or git clone https://github.com/zedshaw/python-lust.git
What about security?
Two options:
1- Host your own server that has git on it
2- Pay github (or others) monthly and you get private repos that you can control
You control who can commit to your project even in the free github accounts
Workflow
1- Ensure that you are on the CORRECT branch. (This is vital later on…)
2- Make modifications to your code. (SAVE the changes.)
3- Add the files to the staging area.
4- Commit the changes to your local repo.
5- Merge your Dev branch with your Master branch.
6- Push the changes to your remote repo.
git init
fivestringbass:EJv2 brian$ touch index.htm
fivestringbass:EJv2 brian$ git init
Initialized empty Git repository in /Users/brian/Google
Drive/Code/JavaScript/EJv2/.git/
git status
fivestringbass:EJv2 brian$ git status
# On branch master
# Initial commit
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
# ch2exa.js
# index.htm
nothing added to commit but untracked files present (use "git add" to track)
git add
fivestringbass:EJv2 brian$ git add .
(You can specify particular files if someone else in your team needs them, or you
can use the period, which signifies adding everything in the current directory and
subdirectories.)
git status (again)
fivestringbass:EJv2 brian$ git status
# On branch master
# Initial commit
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
# new file: ch2exa.js
# new file: index.htm
git commit
fivestringbass:EJv2 brian$ git commit -m "Initial commit. Start of project."
[master (root-commit) de4ed60] Initial commit. Start of project.
2 files changed, 16 insertions(+)
create mode 100644 ch2exa.js
create mode 100644 index.htm
git status (yet again)
fivestringbass:EJv2 brian$ git status
# On branch master
nothing to commit, working directory clean
fivestringbass:EJv2 brian$
Wash, Rinse, and Repeat
How often to commit?
Whenever you make a major change.
Make changes and repeat
fivestringbass:EJv2 brian$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# modified: ch2exa.js
no changes added to commit (use "git add" and/or "git commit -a")
How do I see my changes?
1)git log
2)use gitk --all (MAY need a separate install)
.gitignore
Specifies intentional untracked files & folders that Git should ignore
.DS_Store files (if using a MAC)
data/ ( if you are processing data that is temporary)
Can use regular expressions to specify the pattern to look for
Can ignore all .php files with *.php EXCEPT you can add !index.php to have git
track changes to that one php file
git revert
Used to “undo” a commit.
Similar to the Previous Versions feature in Windows Server.
git revert SHA# or git revert HEAD
git reset --soft SHA# ( resets the HEAD to the point you specify but doesn’t alter
staging index or working directory)
git reset --hard SHA# (very destructive- changes staging index and working
directory to match the repo- all future changes are GONE!)
Remote repositories
to view: git remote -v
to add a remote: make directory (repo.git) on the remote git server, CD to it and
type “git init --bare”
then on your dev machine, cd to your folder, then type “git remote add
REMOTENAME USER@HOST:/USERNAME/REPO_NAME”
for github, it would be: git remote add github
https://github.com/bkvagnini/REPO.git
git branch
To see what branches are available: “git branch”
To create a new branch: “git branch develop”
To use a different branch: “git checkout develop”
To create a new branch and switch to it: “git checkout -b develop
To delete a branch: “git branch -d dev”
git merge
(from your develop branch, in a clean state)
git checkout master
git merge develop
git checkout develop
WRITE CODE!
merge conflicts (look for the >>> and <<< in the document)
Revised workflow
git fetch origin master
git pull origin master
git checkout develop
git merge master
change files
test and verify (The add to staging and commit to local repo steps are done here)
git checkout master
git merge develop
code review
git push origin master
git stash
Saves changes to your code in progress without committing them to the repo
git stash save “message”
git stash list (views stash changes)
Retrieve your stash
git stash pop stash@{0} (removes the changes from the stash)
git stash apply stash@{0} (leaves a copy in the stash)
-Deleting your stash
git stash drop stash@{0}
git stash list to confirm
Questions?
Thanks for coming!

More Related Content

What's hot

Git github
Git githubGit github
Git github
Anurag Deb
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
Nilay Binjola
 
Git Basics at Rails Underground
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails Underground
Ariejan de Vroom
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginners
bryanbibat
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
David Newbury
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
Daniel Kummer
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
Pham Quy (Jack)
 
Version control system & how to use git
Version control system & how to use git Version control system & how to use git
Version control system & how to use git
Ahmed Dalatony
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
Yodalee
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
KMS Technology
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
Lucas Videla
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
Mohammad Imam Hossain
 
Git advanced
Git advancedGit advanced
Git advanced
Peter Vandenabeele
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
Jason Byrne
 
Git workshop
Git workshopGit workshop
Git workshop
Mateusz Galazyn
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
Suman Mukherjee
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
E Carter
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
Elli Kanal
 

What's hot (20)

Git github
Git githubGit github
Git github
 
Git - Basic Crash Course
Git - Basic Crash CourseGit - Basic Crash Course
Git - Basic Crash Course
 
Git training
Git trainingGit training
Git training
 
Git Basics at Rails Underground
Git Basics at Rails UndergroundGit Basics at Rails Underground
Git Basics at Rails Underground
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginners
 
Introduction to Git for Artists
Introduction to Git for ArtistsIntroduction to Git for Artists
Introduction to Git for Artists
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Version control system & how to use git
Version control system & how to use git Version control system & how to use git
Version control system & how to use git
 
Git: basic to advanced
Git: basic to advancedGit: basic to advanced
Git: basic to advanced
 
Git Version Control System
Git Version Control SystemGit Version Control System
Git Version Control System
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
GIT | Distributed Version Control System
GIT | Distributed Version Control SystemGIT | Distributed Version Control System
GIT | Distributed Version Control System
 
Git advanced
Git advancedGit advanced
Git advanced
 
Hello git
Hello git Hello git
Hello git
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Git workshop
Git workshopGit workshop
Git workshop
 
Git vs svn
Git vs svnGit vs svn
Git vs svn
 
The everyday developer's guide to version control with Git
The everyday developer's guide to version control with GitThe everyday developer's guide to version control with Git
The everyday developer's guide to version control with Git
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 

Viewers also liked

Git - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCSGit - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCS
Matthew McCullough
 
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro WorkshopOpen Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Wong Hoi Sing Edison
 
Intro to Git for Drupal 7
Intro to Git for Drupal 7Intro to Git for Drupal 7
Intro to Git for Drupal 7
Chris Caple
 
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgit
Geshan Manandhar
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
Lee Hanxue
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
Uri Goldstein
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
Yoad Snapir
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
Anurag Upadhaya
 
Git - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCSGit - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCS
Matthew McCullough
 
Intro To Git
Intro To GitIntro To Git
Intro To Git
kyleburton
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to gitJoel Krebs
 

Viewers also liked (11)

Git - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCSGit - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCS
 
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro WorkshopOpen Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
Open Innovation Lab (OIL) - 20150227 - GIT Intro Workshop
 
Intro to Git for Drupal 7
Intro to Git for Drupal 7Intro to Git for Drupal 7
Intro to Git for Drupal 7
 
Git intro hands on windows with msysgit
Git intro hands on windows with msysgitGit intro hands on windows with msysgit
Git intro hands on windows with msysgit
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Intro to Git and GitHub
Intro to Git and GitHubIntro to Git and GitHub
Intro to Git and GitHub
 
Basic Git Intro
Basic Git IntroBasic Git Intro
Basic Git Intro
 
Git 101 for Beginners
Git 101 for Beginners Git 101 for Beginners
Git 101 for Beginners
 
Git - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCSGit - Intro to the Basics of DVCS
Git - Intro to the Basics of DVCS
 
Intro To Git
Intro To GitIntro To Git
Intro To Git
 
Quick Introduction to git
Quick Introduction to gitQuick Introduction to git
Quick Introduction to git
 

Similar to Intro to Git DevOps Tally Presentation 101615

Git and github 101
Git and github 101Git and github 101
Git and github 101
Senthilkumar Gopal
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)
bryanbibat
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
Nguyen Van Hung
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
Grace Chien
 
Git
GitGit
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践Terry Wang
 
Git introduction
Git introductionGit introduction
Git introduction
satyendrajaladi
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践Terry Wang
 
Git
GitGit
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
Chris Johnson
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
UshaSuray
 
Git
GitGit
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Aleksey Asiutin
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
Raja Soundaramourty
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
Rifauddin Tsalitsy
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
themystic_ca
 
HackMTY - GitHub Workshop
HackMTY - GitHub WorkshopHackMTY - GitHub Workshop
HackMTY - GitHub Workshop
Luis Lamadrid
 

Similar to Intro to Git DevOps Tally Presentation 101615 (20)

Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
 
Loading...git
Loading...gitLoading...git
Loading...git
 
GIT_In_90_Minutes
GIT_In_90_MinutesGIT_In_90_Minutes
GIT_In_90_Minutes
 
Git
GitGit
Git
 
Git
GitGit
Git
 
Git 入门与实践
Git 入门与实践Git 入门与实践
Git 入门与实践
 
Git introduction
Git introductionGit introduction
Git introduction
 
Git 入门 与 实践
Git 入门 与 实践Git 入门 与 实践
Git 入门 与 实践
 
Git
GitGit
Git
 
Git Tech Talk
Git  Tech TalkGit  Tech Talk
Git Tech Talk
 
sample.pptx
sample.pptxsample.pptx
sample.pptx
 
Git
GitGit
Git
 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
 
Working in Team using Git in Unity
Working in Team using Git in UnityWorking in Team using Git in Unity
Working in Team using Git in Unity
 
Introduction To Git Workshop
Introduction To Git WorkshopIntroduction To Git Workshop
Introduction To Git Workshop
 
HackMTY - GitHub Workshop
HackMTY - GitHub WorkshopHackMTY - GitHub Workshop
HackMTY - GitHub Workshop
 

Intro to Git DevOps Tally Presentation 101615

  • 1. Intro to Git presented by Brian K. Vagnini Hosted by
  • 2. What is version control? Local Version Control Centralized Version Control Distributed Version Control
  • 3. What is Git Software that stores a snapshot of your files Everything is local to your machine Does a SHA-1 checksum and stores that for each snapshot
  • 5. Three sections of a git project Working directory Staging area git repo
  • 6. Installing git Linux - yum install git-core (or apt-get install git-core) Mac - using macports, sudo port install git-core or browse to git-scm.com/download/mac Windows - msysgit.github.com post install git config --global user.name ‘Your Name’ git config --global user.email youremail@domain.com
  • 7. Getting help Google Offline: git help <verb> git <verb> --help man git <verb>
  • 8. Getting started 1- Existing folder with files and no version control git init git add . git commit -m “Your message here” 2- Nothing at all- Cloning an existing repo git clone https://github.com/vinta/awesome-python.git or git clone https://github.com/zedshaw/python-lust.git
  • 9. What about security? Two options: 1- Host your own server that has git on it 2- Pay github (or others) monthly and you get private repos that you can control You control who can commit to your project even in the free github accounts
  • 10. Workflow 1- Ensure that you are on the CORRECT branch. (This is vital later on…) 2- Make modifications to your code. (SAVE the changes.) 3- Add the files to the staging area. 4- Commit the changes to your local repo. 5- Merge your Dev branch with your Master branch. 6- Push the changes to your remote repo.
  • 11. git init fivestringbass:EJv2 brian$ touch index.htm fivestringbass:EJv2 brian$ git init Initialized empty Git repository in /Users/brian/Google Drive/Code/JavaScript/EJv2/.git/
  • 12. git status fivestringbass:EJv2 brian$ git status # On branch master # Initial commit # Untracked files: # (use "git add <file>..." to include in what will be committed) # ch2exa.js # index.htm nothing added to commit but untracked files present (use "git add" to track)
  • 13. git add fivestringbass:EJv2 brian$ git add . (You can specify particular files if someone else in your team needs them, or you can use the period, which signifies adding everything in the current directory and subdirectories.)
  • 14. git status (again) fivestringbass:EJv2 brian$ git status # On branch master # Initial commit # Changes to be committed: # (use "git rm --cached <file>..." to unstage) # new file: ch2exa.js # new file: index.htm
  • 15. git commit fivestringbass:EJv2 brian$ git commit -m "Initial commit. Start of project." [master (root-commit) de4ed60] Initial commit. Start of project. 2 files changed, 16 insertions(+) create mode 100644 ch2exa.js create mode 100644 index.htm
  • 16. git status (yet again) fivestringbass:EJv2 brian$ git status # On branch master nothing to commit, working directory clean fivestringbass:EJv2 brian$
  • 17. Wash, Rinse, and Repeat How often to commit? Whenever you make a major change.
  • 18. Make changes and repeat fivestringbass:EJv2 brian$ git status # On branch master # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # modified: ch2exa.js no changes added to commit (use "git add" and/or "git commit -a")
  • 19. How do I see my changes? 1)git log 2)use gitk --all (MAY need a separate install)
  • 20.
  • 21. .gitignore Specifies intentional untracked files & folders that Git should ignore .DS_Store files (if using a MAC) data/ ( if you are processing data that is temporary) Can use regular expressions to specify the pattern to look for Can ignore all .php files with *.php EXCEPT you can add !index.php to have git track changes to that one php file
  • 22. git revert Used to “undo” a commit. Similar to the Previous Versions feature in Windows Server. git revert SHA# or git revert HEAD git reset --soft SHA# ( resets the HEAD to the point you specify but doesn’t alter staging index or working directory) git reset --hard SHA# (very destructive- changes staging index and working directory to match the repo- all future changes are GONE!)
  • 23. Remote repositories to view: git remote -v to add a remote: make directory (repo.git) on the remote git server, CD to it and type “git init --bare” then on your dev machine, cd to your folder, then type “git remote add REMOTENAME USER@HOST:/USERNAME/REPO_NAME” for github, it would be: git remote add github https://github.com/bkvagnini/REPO.git
  • 24. git branch To see what branches are available: “git branch” To create a new branch: “git branch develop” To use a different branch: “git checkout develop” To create a new branch and switch to it: “git checkout -b develop To delete a branch: “git branch -d dev”
  • 25. git merge (from your develop branch, in a clean state) git checkout master git merge develop git checkout develop WRITE CODE! merge conflicts (look for the >>> and <<< in the document)
  • 26. Revised workflow git fetch origin master git pull origin master git checkout develop git merge master change files test and verify (The add to staging and commit to local repo steps are done here) git checkout master git merge develop code review git push origin master
  • 27. git stash Saves changes to your code in progress without committing them to the repo git stash save “message” git stash list (views stash changes)
  • 28. Retrieve your stash git stash pop stash@{0} (removes the changes from the stash) git stash apply stash@{0} (leaves a copy in the stash) -Deleting your stash git stash drop stash@{0} git stash list to confirm

Editor's Notes

  1. Concurrent Versioning System (CVS) and Subversion (SVN) are examples of Centralized. Mercurial and Git are examples of Distributed.
  2. demo this and show them how to get out of the man page (q)
  3. Python Little Unix Server Toolkit
  4. Point out the de4ed60 (it’s the first part of the 40 character SHA-1 string)
  5. vs. git log -5 (show on vagnini.net website)
  6. When demoing this, point out the SHA-1 ID field, reminding them of the Commit response they got back- also point out that your command line is not returned to you until you exit Wish (at least on a MAC)
  7. Look at vagnini.net .DS_Store is for MAC, the .htm~ is for the temp files that get created when editing .htm files
  8. Once you rewind/reset, your log won’t show you the commits- save them in a text file - can see where HEAD is via cat .git/HEAD or cat .git/refs/heads/master (shows you the SHA#)
  9. Look in /Users/brian/Google Drive/from_dropbox/Projects/cala-learn or /learning_files/python_book (has 2 remote repos) git remote -v github acct bkvagnini:korea hill pw http://git-scm.com/docs/git-remote
  10. look at 24thbay website for develop vs. master branch git branch -r (shows remote branches) or git branch -a (shows local and remote branches)
  11. occurs mainly when two or more team members try to modify the same file at the same time
  12. origin is this case is the name of the remote repo that you had created earlier
  13. make a change and save it- DO NOT COMMIT- change branches- git yells at you-
  14. Look at /from_dropbox09websites/vagnini website for stashes in the develop branch- show using gitk --all - demo pop and apply then drop - demo with git stash list