DEVNET-1080 Introduction to Git Ashley Roach Principal Engineer Evangelist Twitter: @aroach Email: asroach@cisco.com
Cisco Spark How Questions? Use Cisco Spark to communicate with the speaker after the session 1. Find this session in the Cisco Live Mobile App 2. Click Join the Discussion 3. Install Spark or go directly to the space 4. Enter messages/questions in the space cs.co/ciscolivebot#devnet-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Agenda Introduction Quick overview of Git Workshop Resources
WHY ARE WE HERE? It s kindof like: - Snapshots of VMs - Incremental backups of files - Wiki versioning When you make a mistake or want to do some experimenting, you can do that in a safe way DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 7
Why version control? To Protect yourself and others
What does this have to do with Networking or Data Center?
NetDevOps CICD Pipeline Demonstration Create Proposed Branch Update Configuration Test Configuration Push Proposed Changes Send Notification Deploy Changes and Test Build Test Network Build Automation Starts Automated Pipeline Credit: Hank Preston DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 10
See also DEVNET-2203 Build a Network Configuration CICD Pipeline (Thurs, Feb 1, 0900 DEVNET-1725 How to Be a Network Engineer in a Programmable Age (Tues, Jan 30, 1300) DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 11
Git vs. GitHub Git is an open source distributed version control system / technology GitHub is a commercial company, that runs GitHub.com based on Git VCS DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 12
Git: Technical Overview
DISTRIBUTED VERSION CONTROL Opens up to new workflows: git flow Each system has an exact replica of the repo as other collaborators. https://git-scm.com/images/about/workflow-b@2x.png DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 14
Under the hood Changes are stored in trees Trees contain changed files Commits contain trees http://git-scm.com/figures/18333fig0903-tn.png DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 15
Getting Started with Git Starting from GitHub (screenshot flow of new project) Starting from your workstation (git init) DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 16
Getting Started with CLI: GIT CONFIG So you can be held accountable, configure git $ git config --global user.name "Your Name Comes Here" $ git config --global user.email you@yourdomain.example.com DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 17
Getting Started: Cloning Projects No password Set up SSH key on remote server (e.g. ssh-keygen) $ git clone git@github.com:aroach/upgraded-guacamole.git $ git clone https://github.com/aroach/upgraded-guacamole.git DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 18
Getting Started: Local Repository DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 19
What s inside.git? DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 20
DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 22
GIT ADD Add any files in your repository to git stage https://git-scm.com/images/about/index1@2x.png $ git add. 24 DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
STAGING AREA Hat tip: @GeorgiaReh DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 25
GIT COMMIT Store your changes into a commit Saves all of your changes together / save point Commit does NOT push $ git commit m Initial commit DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 26
Git Log: History of commits DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 27
BRANCHING: Your safe place Makes a pointer to your code Moves HEAD around $ git branch <name> $ git branch testing $ git commit m new $ git checkout master http://git-scm.com/figures/18333fig0307-tn.png DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 28
MERGING git merge <topic> You must be on the branch you want to merge INTO when you execute this command (e.g. master) $ git merge <branch> DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 29
GOING BACKWARDS Generate a new commit that undoes all of the changes introduced in <commit>, then apply it to the current branch. $ git revert <commit> DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 30
SHARE YOUR CHANGES git push <destination> <branch> git push origin master $ git remote add <name> <url> $ git push <name> <branch> $ git push origin master DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 31
GIT CLIENTS CLI Client IDE Clients VIM: airblade/vim-gitgutter Emacs: magit GUI Clients SourceTree Git Kracken DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 32
DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 35
DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 36
Come find me after today I ll be waiting Ashley Roach asroach@cisco.com @aroach http://github.com/aroach http://linkedin.com/in/ashleyroach Cisco DEVNET @CiscoDevNet http://github.com/ciscodevnet DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 37
Cisco Spark How Questions? Use Cisco Spark to communicate with the speaker after the session 1. Find this session in the Cisco Live Mobile App 2. Click Join the Discussion 3. Install Spark or go directly to the space 4. Enter messages/questions in the space cs.co/ciscolivebot#devnet-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Please complete your Online Session Evaluations after each session Complete 4 Session Evaluations & the Overall Conference Evaluation (available from Thursday) to receive your Cisco Live T-shirt All surveys can be completed via the Cisco Live Mobile App or the Communication Stations Complete Your Online Session Evaluation Don t forget: Cisco Live sessions will be available for viewing on-demand after the event at www.ciscolive.com/global/on-demand-library/. 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public
Continue Your Education Demos in the Cisco campus Walk-in Self-Paced Labs Tech Circle Meet the Engineer 1:1 meetings Related sessions DEVNET-1080 2018 Cisco and/or its affiliates. All rights reserved. Cisco Public 40
Thank you