22

Intro to Git: a hands-on workshop

Embed Size (px)

Citation preview

Page 1: Intro to Git: a hands-on workshop
Page 2: Intro to Git: a hands-on workshop

Introduction to GitAshley Roach -- API Architect – DevNet

Twitter: @aroach

Email: [email protected]

Page 3: Intro to Git: a hands-on workshop

• Introduction

• Quick overview of Git

• Workshop

• Resources

Agenda

Page 4: Intro to Git: a hands-on workshop

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!

Page 5: Intro to Git: a hands-on workshop

WHY ARE WE HERE?

5

Page 6: Intro to Git: a hands-on workshop

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

Page 7: Intro to Git: a hands-on workshop

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]

Page 8: Intro to Git: a hands-on workshop

Under the hood

• Changes are stored in trees

• Trees contain changed files

• Commits contain trees

8

http://git-scm.com/figures/18333fig0903-tn.png

Page 9: Intro to Git: a hands-on workshop

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]

Page 10: Intro to Git: a hands-on workshop

GIT INIT

• Initializes a project directory with a hidden directory /.git/

10

$ tar xzf project.tar.gz

$ cd project

$ git init

Page 11: Intro to Git: a hands-on workshop

GIT ADD

• Add any files in your repository to git “stage”

11

$ git add .

https://git-scm.com/images/about/[email protected]

Page 12: Intro to Git: a hands-on workshop

GIT COMMIT

• Store your changes into a commit

12

$ git commit –m ’Initial commit’

Page 13: Intro to Git: a hands-on workshop

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

Page 14: Intro to Git: a hands-on workshop

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>

Page 15: Intro to Git: a hands-on workshop

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

Page 16: Intro to Git: a hands-on workshop

SHARE YOUR CHANGES

• git push <destination> <branch>

• git push origin master

16

$ git push <destination> <branch>

$ git push origin master

Page 17: Intro to Git: a hands-on workshop

Workshop

17

Page 18: Intro to Git: a hands-on workshop

Let’s get started

• http://bit.ly/git-berlin

18

Page 19: Intro to Git: a hands-on workshop

Additional Resources

• https://training.github.com/kit/downloads/github-git-cheat-sheet.pdf

• https://www.atlassian.com/git/tutorials/comparing-workflows/

19

Page 20: Intro to Git: a hands-on workshop

Contact

• Ashley Roach

[email protected]

• @aroach

20

CLEUR DevNet Zone Story

Page 21: Intro to Git: a hands-on workshop

Thank you

Page 22: Intro to Git: a hands-on workshop