Git Cookbook For Devops Network Systems Management 3
Git Cookbook For Devops Network Systems Management 3
Stream of snapshots
Key difference between Git and other
version control systems is that Git stores
data as snapshots instead of differences
(the delta between the current file and the
previous version)
git push -u
is important for syncing your local git repository with your remote git
repository when pushing to remote for the first time. The advantage is, you
may use git pull without any arguments.
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 18
Git clone
When using git clone (from GitHub, or any source repository) the default name for
the source of the clone is "origin".
Using git remote show will display the information about this remote name.
Here is a method to find the url of the remote url for the name
origin
Example $ git config --get remote.origin.url
Response:
https://github.com/yroosel/python_scripts.git
Remote Git Repository URL (2)
Here is a method to find the url of the remote url both for
fetching or for pushing
Example $ git remote -v
Response:
origin https://github.com/yro/python_scripts.git (fetch)
origin https://github.com/yro/python_scripts.git (push)
Remote Git Remote Repository Details
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 31
Git branching
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 33
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 34
*Main is often used as a replacement of master
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 35
Comparing changes with git diff
● Diffing is a function that takes two input data sets and outputs the changes
between them
● git diff is a multi-use Git command that when executed runs a diff function on
Git data sources.
● These data sources can be commits, branches, files and more
Comparing changes with git diff (2)
Comparison input
Example:
index 5c3b621..a0d8bf9 100644
Comparing changes with git diff (3)
Markers for changes
These lines are a legend that assigns symbols to each diff input source.
In this case, changes from a/diff_test.txt are marked with a --- and the changes
from b/diff_test.txt are marked with the +++ symbol.
Comparing changes with git diff (4)
Diff chunks
A diff only displays the sections of the file that have changes.
The example shows that one line was deleted and one line was added.
This indicates a replacement or an update
Comparing changes with git diff (5)
Comparing files from two branches
def main():
print (add(100,10))
+ print (subtract(100,10))
+ print (multiply(100,10))
+ print (divide(100,10))
Downloading git existing repository
$ git config --global user.email "[email protected]"
$ git init
$ git status
Tips for Deploying Python Applications
Create a Python Virtual Environment
Create branches and test code before merging into main branch
CI/CD Pipeline
GitLab
Jenkins Pipeline => Stages
The main role of Jenkins is to execute the stages of
a pipeline and to verify/ test the results
BuildFlaskAppJob
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 60
Use Personal Access Token
In place of password
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 61
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 62
stages
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 63
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 64
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 65
Practical Examples
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 66
Git fork vs. clone: What's the difference?
$ git branch
$ git fetch
$ git diff
$ git remote -v
$ git add .
$ git status
© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 72
Infrastructure Automation: IaC Tooling Comparison
Infrastructure as Code, Repositories => Git
Getting Started
Git Basics
Git Branching
Git on the Server
Distributed Git
GitHub
Git Tools
…
References
Cisco Networking Academy, DevNet Associate 1.0 (DEVASC)
URL: www.netacad.com
Login necessary