2. Murughan Palaniachari
Principal Consultant – DevOps and Blockchain
Organizer of
Cloud and DevOps meetup
Technical Agility Conference
http://aidevdays.com/
http://www.containerconf.in/
https://elevate-org.com/
https://devopsgames.com/
https://in.linkedin.com/in/murughan
@Murughan_P
With my Guru – John Willis & Jez Humble
4. What is Visual
Studio Team
Services?
• It’s a source control system!
• Wrong. It is FAR more than a source control
system.
• Everything you need to create software.
From application inception to application sun
setting.
• DevOps Collaboration Hub
• Key Functional Areas
• Agile Planning & Management/Work Item
Tracking
• Version Control
• Build Management & Automation
• Testing
• Release Management
• Application Monitoring
@Murughan_P
5. REQUIREMENTS
Plan
Develop + Test Release
Business
Product Owners
Developers
Testers
Operations
+ all other
Stakeholders
Backlog
Enabling Value Delivery
@Murughan_P
6. Agenda –
Version Control
• Version Control Overview
• Centralized Version Control
• Distributed Version Control
• Git Overview
• Pre-requisites
• Git Installation
• Git Commands
• Branching, Merging, Rebase
• Trunk based approach
• Pull request
• Code review
• Workshop with sample Python Application
@Murughan_P
7. Training
Exercises
• Exercise 1: Practise Git commands – command
line
• Exercise 2: Create Git repository in VSTS, clone
it, git commands through Visual Studio
• Exercise 3: Trunk based approach, create
branch, create pull request and approve.
• Exercise 4: Unit testing with Unittest python
for sample Phonebook app
• Exercise 5: Mock data with Unittest Mock
package python for sample bank accounts app
• Exercise 6: TDD for sample Calculator app
• Demo: UI Testing with Selenium Web Driver
python
@Murughan_P
9. Version Control
• Version Control as Fundamental Enabler of Continuous Delivery
• One single source of truth for everything
• Manage your daily tasks
• Create
• Save
• Edit
• Save again
• Collaborative History tracking
• What changes
• Why was things changed – comments
• Compare the changes
• Who has made change
https://git-scm.com/ @Murughan_P
11. Git - Distributed Version Control
• Git is a fast and modern implementation of Version Control
• Git is a fast, scalable, distributed revision control system with an
unusually rich command set that provides both high-level operations
and full access to internals.
• Git provides a history of content changes
• Git facilitates Collaborative Changes to files
• East to use for anyone and any knowledge worker
• Local Git
• Easy to learn
https://git-scm.com/ @Murughan_P
12. Git - Distributed Version Control
https://app.pluralsight.com/library/courses/tfs-visual-studio-2015-implementing-continuous-delivery/table-of-contents
@Murughan_P
13. Principle - Keep everything in Source Control
https://www.edx.org/course/introduction-devops-transforming-linuxfoundationx-lfs161x @Murughan_P
14. Git Installation
• Windows
• https://git-scm.com/downloads
• Mac OSX
• https://git-scm.com/download/mac
• Linux
• https://git-
scm.com/download/linux
@Murughan_P
15. The Three States committed, modified, and staged
• Committed means that
the data is safely stored in
your local database.
• Modified means that you
have changed the file but
have not committed it to
your database yet.
• Staged means that you
have marked a modified
file in its current version to
go into your next commit
snapshot.
https://git-scm.com/book/en/v2/Getting-Started-Git-Basics @Murughan_P
17. Git commands list
• git
• git --version
• Prints the Git suite version that
the git program came from.
• git --help
• Prints the synopsis and a list of
the most commonly used
commands. Ex: git --help merge
https://git-scm.com/docs/git @Murughan_P
18. Configuring Git
Git comes with a tool called git config that
lets you get and set configuration variables
that control all aspects of how Git looks and
operates.
• System-level configuration
• git config --system
• Stored in /etc/gitconfig or
c:Program Files
(x86)Gitetcgitconfig
• User-level configuration
• git config --global
• Stored in ~/.gitconfig or
c:Users<NAME>.gitconfig
@Murughan_P
19. Configuring Git
• Repository-level configuration
• git config
• Stored in .git/config in each repo
• Set Identity
• git config --global user.name "John
Doe"
• git config --global user.email
johndoe@example.com
• Check your seetings
• git config --list
@Murughan_P
20. Git commands
• Creating a local repository
• git init sampleproject
• cd sampleproject
• Open this folder in editor and add some test files
• Adding files
• git add .
• Committing changes – local commit
• git commit -m "Creating sample project“
• Cloning app
• Git clone https://github.com/murughan1985/pythonSample.git
@Murughan_P
21. STAGE &
SNAPSHOT
Working with snapshots and the Git staging area
• git add [file]
• add a file as it looks now to your next commit
(stage)
• git status
• show modified files in working directory, staged
for your next commit
• git reset [file]
• unstage a file while retaining the changes in
working directory
• git diff //modify the test file
• - diff of what is changed but not staged
• git diff –staged
• diff of what is staged but not yet commited
• git commit -m “[descriptive message]”
• commit your staged content as a new commit
snapshot
@Murughan_P
22. Log
@Murughan_P
• show the commit history for the currently active branchgit log
• show the commits on branchA that are not on branchBgit log branchB..branchA
• show the commits that changed file, even across renamesgit log --follow [file]
• show the diff of what is in branchA that is not in branchBgit diff branchB...branchA
• show any object in Git in human-readable formatgit show [SHA]
23. Exercise 2
Create Git repository in VSTS, clone it, git commands
through Visual Studio
@Murughan_P
24. VSTS – Git tab
• Repository
• Create New Repository
• Import New repository
• Manage Repository
• Clone and Fork
• Files
• Content
• History
• Commits
• Pushes
• Tags
https://www.youtube.com/watch?v=ykZbBD-CmP8 @Murughan_P
25. Github – Create python Django project from visual studio and push
it to github
Workshop
Check out my blogpost on this
https://elevate-org.com/2018/05/13/create-python-django-project-from-visual-studio-and-
push-it-to-github/
@Murughan_P
26. SHARE & UPDATE
@Murughan_P
• add a git URL as an aliasgit remote add [alias] [url]
• fetch down all the branches from that Git remotegit fetch [alias]
• merge a remote branch into your current branch to bring it up to dategit merge [alias]/[branch]
• Transmit local branch commits to the remote repository branchgit push [alias] [branch]
• fetch and merge any commits from the tracking remote branchgit pull
27. TRACKING PATH CHANGES
@Murughan_P
• delete the file from project and stage the removal for
commitgit rm [file]
• change an existing file path and stage the move
git mv [existing-path]
[new-path]
• show all commit logs with indication of any paths
that movedgit log --stat -M
28. Git commands
• Branch
• git branch feature1
• Merge changes to master
• git merge sampleproject
• Rebase - you can take all the changes
that were committed on one branch
and replay them on another one.
• git checkout fature1
• git rebase master
• Stage - Add file contents to the staging
area
• git stage
@Murughan_P
29. Create VSTS
project and Git
repository.
Workshop
Check out my blogpost on this
https://elevate-
org.com/2018/05/13/configure-git-
version-control-in-vsts-and-create-push-
python-django-project-through-visual-
studio/
@Murughan_P
30. Branching and
Merging
• Branching means you diverge from the main
line of development and continue to do work
without messing with that main line.
• The way Git branches is incredibly lightweight,
making branching operations nearly
instantaneous, and switching back and forth
between branches generally just as fast.
• Below command create branch called feature1
from master
• git branch feature1
• Merging Join two or more development
histories together
• git merge feature1
• Staging Add file contents to the staging area
@Murughan_P
33. Trunk based
approach
• A source-control branching model,
where developers collaborate on
code in a single branch called ‘trunk’.
• Resist any pressure to create other
long-lived development branches by
employing documented techniques.
• They therefore avoid merge hell, do
not break the build, and live happily
ever after.
@Murughan_Phttps://trunkbaseddevelopment.com/
37. BRANCH &
MERGE
Isolating work in branches, changing context, and
integrating changes
• git branch
• list your branches. a * will appear next to the
currently active branch
• git branch [branch-name]
• create a new branch at the current commit
• git checkout
• switch to another branch and check it out
into your working directory
• git merge [branch]
• merge the specified branch’s history into the
current one
• git log
• show all commits in the current branch’s
history
@Murughan_P
38. Pull request
• The pull request is the collaborative process that lets the rest
of the team discuss changes in a branch and agree to merge
them once everyone approves. Use pull requests to get early
feedback from others on work in progress, even if you're not
ready to merge the changes into another branch.
• In this image, the purple branch is merged into the blue branch
through a pull request. The changes are discussed by reviewers
in the pull request before the code is merged. When you
complete the pull request, there is a merge commit (seen here
as the filled blue commit) where the changes in the purple
branch are now merged in the blue branch.
@Murughan_P
39. Exercise 3
Trunk based approach, create branch,
create pull request and approve with
VSTS and Visual Studio
@Murughan_P