Intro to Git: a hands-on workshop
-
Upload
cisco-devnet -
Category
Technology
-
view
380 -
download
0
Transcript of Intro to Git: a hands-on workshop
![Page 1: Intro to Git: a hands-on workshop](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/1.jpg)
![Page 3: Intro to Git: a hands-on workshop](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/3.jpg)
• Introduction
• Quick overview of Git
• Workshop
• Resources
Agenda
![Page 4: Intro to Git: a hands-on workshop](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/4.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/5.jpg)
WHY ARE WE HERE?
5
![Page 6: Intro to Git: a hands-on workshop](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/6.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/7.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/8.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/9.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/10.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/11.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/12.jpg)
GIT COMMIT
• Store your changes into a commit
12
$ git commit –m ’Initial commit’
![Page 13: Intro to Git: a hands-on workshop](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/13.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/14.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/15.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/16.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/17.jpg)
Workshop
17
![Page 19: Intro to Git: a hands-on workshop](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/19.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/20.jpg)
Contact
• Ashley Roach
• @aroach
20
CLEUR DevNet Zone Story
![Page 21: Intro to Git: a hands-on workshop](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/21.jpg)
Thank you
![Page 22: Intro to Git: a hands-on workshop](https://reader031.fdocuments.us/reader031/viewer/2022030307/58e755b41a28ab91558b64d1/html5/thumbnails/22.jpg)