git commit

Report 6 Downloads 137 Views
Introduction to Git Ashley Roach, Dev Evangelist APIs and Cloud – DevNet @aroach [email protected] DEVNET-1080

Agenda



Introduction



Quick overview of Git



Workshop



Resources

WHY ARE WE HERE?

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

4

Why version control? To Protect yourself and others

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/[email protected]

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

6

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

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

7

GIT CONFIG •

So you can be held accountable, configure git

$ git config --global user.name "Your Name Comes Here" $ git config --global user.email [email protected]

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

8

GIT INIT •

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

$ tar xzf project.tar.gz $ cd project $ git init

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

9

GIT ADD •

Add any files in your repository to git “stage”

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

$ git add .

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

10

STAGING AREA

Hat tip: @GeorgiaReh

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

11

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

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

12

BRANCHING: Your safe place

$ $ $ $



Makes a pointer to your code



Moves HEAD around git git git git

branch branch testing commit –m “new” checkout master http://git-scm.com/figures/18333fig0307-tn.png

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

13

MERGING •

git merge



You must be on the branch you want to merge INTO when you execute this command (e.g. master)

$ git merge

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

14

GOING BACKWARDS •

Generate a new commit that undoes all of the changes introduced in , then apply it to the current branch.

$ git revert

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

15

SHARE YOUR CHANGES •

git push <destination>



git push origin master

$ git remote add $ git push $ git push origin master

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

16

CLONING PROJECTS (SSH OR HTTPS) •

No password



Set up SSH key on remote server (e.g. ssh-keygen)

$ git clone [email protected]:aroach/upgraded-guacamole.git

$ git clone https://github.com/aroach/upgraded-guacamole.git

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

17

GIT CLIENTS •

CLI Client



IDE Clients • •



VIM: airblade/vim-gitgutter Emacs: magit

GUI Clients • •

SourceTree Git Kracken

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

18

Workshop

Let’s get started

http://bit.ly/devnet-git-intro

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

20

Additional Resources •

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



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

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

21

Contact •

Ashley Roach



[email protected]



@aroach

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

22

Complete Your Online Session Evaluation •

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

Don’t forget: Cisco Live sessions will be available for viewing on-demand after the event at CiscoLive.com/Online

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

23

Continue Your Education •

Demos in the Cisco campus



Walk-in Self-Paced Labs



Lunch & Learn



Meet the Engineer 1:1 meetings



Related sessions

DEVNET-1080

© 2017 Cisco and/or its affiliates. All rights reserved. Cisco Public

24

Q&A

Thank You