Source Control
Alireza Rahmani
Seneca College
Week 5 - Fall 2023
§ What is source control?
§ Centralized Vs Distributed
§ Why use version control?
§ Install Git
Agenda § Git Terminology & Command
§ What is Azure Repos?
§ A version control system (VCS) is a program or set of
programs that tracks changes to a collection of files. One
goal of a VCS is to easily recall earlier versions of
individual files or of the entire project. Another goal is to
allow several team members to work on a project, even
on the same files, at the same time without affecting each
other's work.
What is version
control? § Another name for a VCS is a software configuration
management (SCM) system. The two terms often are used
interchangeably—in fact, Git's official documentation is
located at git-scm.com. Technically, version control is just
one of the practices involved in SCM. A VCS can be used
for projects other than software, including books and
online tutorials.
With a VCS, we can:
• See all the changes made to your project, when the changes
were made, and who made them.
• Include a message with each change to explain the reasoning
behind it.
What can we • Retrieve past versions of the entire project or of individual
files.
do with VCS? • Create branches, where changes can be made experimentally.
This feature allows several different sets of changes (for
example, features or bug fixes) to be worked on at the same
time, possibly by different people, without affecting the main
branch. Later, you can merge the changes you want to keep
back into the main branch.
• Attach a tag to a version—for example, to mark a new
release.
§ Earlier instances of VCSes, including CVS, Subversion
(SVN), and Perforce, used a centralized server to store a
project's history. This centralization meant that the one
server was also potentially a single point of failure.
§ Git is distributed, which means that a project's complete
history is stored both on the client and on the server. You
Distributed can edit files without a network connection, check them in
version control locally, and sync with the server when a connection
becomes available. If a server goes down, you still have a
local copy of the project. Technically, you don't even have
to have a server. Changes could be passed around in e-
mail or shared by using removable media, but no one
uses Git this way in practice.
§
The Git Flow is the most known workflow on this list. It was
created by Vincent Driessen in 2010 and it is based in two
main branches with infinite lifetime:
Branching § master — this branch contains production code. All
Workflows for development code is merged into master in sometime.
Git § develop — this branch contains pre-production code.
When the features are finished then they are merged
into develop.
During the development cycle, a variety of supporting
branches are used:
§ feature-* — feature branches are used to develop new
features for the upcoming releases. May branch off
from develop and must merge into develop.
Branching § hotfix-* — hotfix branches are necessary to act
immediately upon an undesired status of master. May
Workflows for branch off from master and must merge
Git Cont’d into master anddevelop.
§ release-* — release branches support preparation of a
new production release. They allow many minor bug to
be fixed and preparation of meta-data for a release.
May branch off from develop and must merge
into master anddevelop.
Git Terminology
https://www.coredna.com/blogs/what-is-git-and-
github-part-two
§ Install Git on Mac OS X
§ Install Git on Windows
§ Install Git on Linux
Install Git https://www.atlassian.com/git/tutorials/install-git
Git Commands
https://www.atlassian.com/git/glossary
https://www.atlassian.com/git/tutorials/atlassian-
git-cheatsheet
Git Cheat Sheet
GIT BASICS REWRITING GIT HISTORY
git init Create empty Git repo in specified directory. Run with no git commit Replace the last commit with the staged changes and last commit
<directory> arguments to initialize the current directory as a git repository. --amend combined. Use with nothing staged to edit the last commit’s message.
Clone repo located at <repo> onto local machine. Original repo can be Rebase the current branch onto <base>. <base> can be a commit ID,
git clone <repo> git rebase <base>
located on the local filesystem or on a remote machine via HTTP or SSH. branch name, a tag, or a relative reference to HEAD.
git config Define author name to be used for all commits in current repo. Devs Show a log of changes to the local repository’s HEAD.
git reflog
user.name <name> commonly use --global flag to set config options for current user. Add --relative-date flag to show date info or --all to show all refs.
git add Stage all changes in <directory> for the next commit.
<directory> Replace <directory> with a <file> to change a specific file. GIT BRANCHES
git commit -m Commit the staged snapshot, but instead of launching List all of the branches in your repo. Add a <branch> argument to
git branch
"<message>" a text editor, use <message> as the commit message. create a new branch with the name <branch>.
git checkout -b Create and check out a new branch named <branch>.
git status List which files are staged, unstaged, and untracked.
<branch> Drop the -b flag to checkout an existing branch.
Display the entire commit history using the default format.
git log git merge <branch> Merge <branch> into the current branch.
For customization see additional options.
Show unstaged changes between your index and
git diff REMOTE REPOSITORIES
working directory.
git remote add Create a new connection to a remote repo. After adding a remote,
UNDOING CHANGES <name> <url> you can use <name> as a shortcut for <url> in other commands.
git revert Create new commit that undoes all of the changes made in git fetch Fetches a specific <branch>, from the repo. Leave off <branch>
<commit> <commit>, then apply it to the current branch. <remote> <branch> to fetch all remote refs.
Remove <file> from the staging area, but leave the working directory Fetch the specified remote’s copy of current branch and
git reset <file> git pull <remote>
unchanged. This unstages a file without overwriting any changes. immediately merge it into the local copy.
Shows which files would be removed from working directory. git push Push the branch to <remote>, along with necessary commits and
git clean -n
Use the -f flag in place of the -n flag to execute the clean. <remote> <branch> objects. Creates named branch in the remote repo if it doesn’t exist.
Visit atlassian.com/git for more information, training, and tutorials
Git Cheat Sheet
Git is the open source distributed version control system that facilitates GitHub activities on
your laptop or desktop. This cheat sheet summarizes commonly used Git command line
instructions for quick reference.
Install Create repositories
GitHub for Windows When starting out with a new repository, you only need to do it
https://windows.github.com once; either locally, then push to GitHub, or by cloning an
existing repository.
GitHub for Mac
$ git init
https://mac.github.com
Turn an existing directory into a git repository
Git for All Platforms
$ git clone [url]
http://git-scm.com
Clone (download) a repository that already exists on
Git distributions for Linux and POSIX systems are available on GitHub, including all of the files, branches, and commits
the official Git SCM web site.
Configure tooling The .gitgnore file
Configure user information for all local repositories Sometimes it may be a good idea to exclude files from being
tracked with Git. This is typically done in a special file named
$ git config --global user.name "[name]" .gitignore . You can find helpful templates for .gitignore
Sets the name you want attached to your commit transactions files at github.com/github/gitignore.
$ git config --global user.email "[email address]"
Sets the email you want attached to your commit transactions
$ git config --global color.ui auto
Enables helpful colorization of command line output
Branches Synchronize changes
Branches are an important part of working with Git. Any Synchronize your local repository with the remote repository
commits you make will be made on the branch you're currently on GitHub.com
“checked out” to. Use git status to see which branch that is.
$ git fetch
$ git branch [branch-name] Downloads all history from the remote tracking branches
Creates a new branch
$ git merge
$ git checkout [branch-name] Combines remote tracking branch into current local branch
Switches to the specified branch and updates the
working directory $ git push
Uploads all local branch commits to GitHub
$ git merge [branch]
$ git pull
Combines the specified branch’s history into the
current branch. This is usually done in pull requests, Updates your current local working branch with all new
but is an important Git operation. commits from the corresponding remote branch on GitHub.
git pull is a combination of git fetch and git merge
$ git branch -d [branch-name]
Deletes the specified branch
§ GitHub is a code hosting platform for version control
and collaboration. It lets you and others work together
What is on projects from anywhere.
GitHub? https://guides.github.com/activities/hello-world/
§ An integrated development environment (IDE) is
a software application that provides comprehensive
facilities to computer programmers for software
development. An IDE normally consists of at least
a source code editor, build automation tools and
What is IDE? a debugger. Some IDEs, such as NetBeans and Eclipse,
contain the necessary compiler, interpreter, or both;
others, such as SharpDevelop and Lazarus, do not.
https://en.wikipedia.org/wiki/Integrated_development_e
nvironment
§ Visual Studio Code is a lightweight and free coding editor
that many software developers use around the world.
§ GitHub is a version-control platform for hosting
development projects.
Visual Studio § Visual Studio Code provides an integrated GitHub
experience, making it easier for you to manage projects
Code from inside your code editor.
&
Github
§ Azure Repos is a set of version control tools that you can
use to manage your code. Whether your software
project is large or small, using version control as soon
as possible is a good idea.
Azure Repos Azure Repos provides two types of version control:
§ Git: distributed version control
§ Team Foundation Version Control (TFVC): centralized
version control
§ This extension allows you to connect to Azure DevOps
Services and Team Foundation Server and provides
support for Team Foundation Version Control (TFVC). It
allows you to monitor your builds and manage your pull
Azure Repos requests and work items for your TFVC or Git source
Extension for repositories. The extension uses your local repository
Visual Studio information to connect to either Azure DevOps Services
or Team Foundation Server 2015 Update 2 (and later).
Code https://marketplace.visualstudio.com/items?itemName=
ms-vsts.team
https://sourceforge.net/software/compare/AWS-CodeCommit-vs-Azure-Repos-vs-Google-Cloud-
Source-Repositories/
§ Introduction to Git Recap | Learn with Dr G
§ Get started with Git in Azure DevOps
§ Use Pull Requests with Azure DevOps
Videos § GitHub Training & Guides
Demo
§ https://bitbucket.org/product/version-control-
software
§ https://www.atlassian.com/git
§ https://learn.microsoft.com/en-
us/training/modules/introduction-to-github-
Resources visual-studio-code/1-introduction
§ https://ourtechroom.com/tech/https-vs-ssh-in-
git/
§ https://medium.com/@patrickporto/4-
branching-workflows-for-git-30d0aaee7bf