Intro to Git: a hands-on workshop
-
Upload
cisco-devnet -
Category
Technology
-
view
382 -
download
0
Transcript of Intro to Git: a hands-on workshop
• Introduction
• Quick overview of Git
• Workshop
• Resources
Agenda
DevNet Zone Challenge – DevNet Zone Mobile App
• Download for iOS or Android
• Sign in with Cisco.com ID (not Cisco Live!)
• Visit Demos, attend Sessions and you’ll be credited through Bluetooth on your device
• Complete Learning Labs and be automatically credited
• Head to Info Desk to get your prize!
• 3 Levels of Prizes at 2, 5 and 10 activities
• Have the InfoDesk Staffer check off your prize collection in the app!
WHY ARE WE HERE?
5
As si618 said on Stack Overflow“Have you ever:
• Made a change to code, realised 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?
• 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?
In these cases, and no doubt others, a version control system should make your life easier.”
6
http://stackoverflow.com/a/1408464
DISTRIBUTED VERSION CONTROL
• Opens up to new workflows: git flow
• Each system has an exact replica of the repo as other collaborators.
7
https://git-scm.com/images/about/[email protected]
Under the hood
• Changes are stored in trees
• Trees contain changed files
• Commits contain trees
8
http://git-scm.com/figures/18333fig0903-tn.png
GIT CONFIG
• So you can be held accountable, configure git
9
$ git config --global user.name "Your Name Comes Here"
$ git config --global user.email [email protected]
GIT INIT
• Initializes a project directory with a hidden directory /.git/
10
$ tar xzf project.tar.gz
$ cd project
$ git init
GIT ADD
• Add any files in your repository to git “stage”
11
$ git add .
https://git-scm.com/images/about/[email protected]
GIT COMMIT
• Store your changes into a commit
12
$ git commit –m ’Initial commit’
BRANCHING: Your safe place
• Makes a pointer to your code
• Moves HEAD around
13
http://git-scm.com/figures/18333fig0307-tn.png
$ git branch <name>
$ git branch testing
$ git commit –m “new”
$ git checkout master
MERGING
• git merge <topic>
• You must be on the branch you want to merge INTO when you execute this command (e.g. master)
14
$ git merge <topic>
Git over SSH vs HTTP
• No password
• Set up SSH key on remote server
15
$ git clone [email protected]:aroach/upgraded-guacamole.git
$ git clone https://github.com/aroach/upgraded-guacamole.git
SHARE YOUR CHANGES
• git push <destination> <branch>
• git push origin master
16
$ git push <destination> <branch>
$ git push origin master
Workshop
17
Additional Resources
• https://training.github.com/kit/downloads/github-git-cheat-sheet.pdf
• https://www.atlassian.com/git/tutorials/comparing-workflows/
19
Contact
• Ashley Roach
• @aroach
20
CLEUR DevNet Zone Story
Thank you