SlideShare a Scribd company logo
1 of 33
Download to read offline
Git Tutorial
By: Ahmed Taha
Software Technical Lead
Agenda
• What is version control
• Benefits of version control systems
• What is Git
• Distributed Development
• Community
• Install Git on Windows
• Cloning an existing repository: git clone
• Git workflow
• Git terms
• Setting up a repository
• Git usage and commands
What is version control
 Version control systems are a category of software tools that help a
software team manage changes to source code over time. Version control
software keeps track of every modification to the code in a special kind of
database. If a mistake is made, developers can turn back the clock and
compare earlier versions of the code to help fix the mistake while
minimizing disruption to all team members.
 Software developers working in teams are continually writing new source
code and changing existing source code. The code for a project, app or
software component is typically organized in a folder structure or "file tree".
One developer on the team may be working on a new feature while
another developer fixes an unrelated bug by changing code, each
developer may make their changes in several parts of the file tree.
 Version control helps teams solve these kinds of problems, tracking every
individual change by each contributor and helping prevent concurrent
work from conflicting. Changes made in one part of the software can be
incompatible with those made by another developer working at the same
time. This problem should be discovered and solved in an orderly manner
without blocking the work of the rest of the team. Further, in all software
development, any change can introduce new bugs on its own and new
software can't be trusted until it's tested. So testing and development
proceed together until a new version is ready.
Benefits of version control systems
 Developing software without using version control is risky, like not having
backups. Version control can also enable developers to move faster and it
allows software teams to preserve efficiency and agility as the team scales
to include more developers.
 Version Control Systems (VCS) have seen great improvements over the past
few decades and some are better than others. VCS are sometimes known
as SCM (Source Code Management) tools or RCS (Revision Control System).
One of the most popular VCS tools in use today is called Git. Git is
a Distributed VCS,
What is Git
 By far, the most widely used modern version control system in the world
today is Git. Git is a mature, actively maintained open source project
originally developed in 2005 by Linus Torvalds, the famous creator of the
Linux operating system kernel. A staggering number of software projects
rely on Git for version control, including commercial projects as well as
open source. Developers who have worked with Git are well represented in
the pool of available software development talent and it works well on a
wide range of operating systems and IDEs (Integrated Development
Environments).
characteristics
 Performance
 The raw performance characteristics of Git are very strong when
compared to many alternatives. Committing new changes,
branching, merging and comparing past versions are all
optimized for performance. The algorithms implemented inside
Git take advantage of deep knowledge about common
attributes of real source code file trees, how they are usually
modified over time and what the access patterns are
 Security
 Git has been designed with the integrity of managed source code
as a top priority. The content of the files as well as the true
relationships between files and directories, versions, tags and
commits, all of these objects in the Git repository are secured with a
cryptographically secure hashing algorithm called SHA1. This
protects the code and the change history against both accidental
and malicious change and ensures that the history is fully traceable.
 With Git, you can be sure you have an authentic content history of
your source code.
 Flexibility
 One of Git's key design objectives is flexibility. Git is flexible in
several respects: in support for various kinds of nonlinear
development workflows, in its efficiency in both small and large
projects and in its compatibility with many existing systems and
protocols.
 Git has been designed to support branching and tagging as first-
class citizens (unlike SVN) and operations that affect branches
and tags (such as merging or reverting) are also stored as part of
the change history. Not all version control systems feature this
level of tracking.
Traceability
 Traceability. Being able to trace each change made to the software and
connect it to project management and bug tracking software
 Git for developers
 Feature Branch Workflow
 One of the biggest advantages of Git is its branching capabilities. Unlike
centralized version control systems, Git branches are cheap and easy to
merge. This facilitates the feature branch workflow popular with many Git
users.

Feature branches provide an isolated environment for every change to
your codebase. When a developer wants to start working on something—
no matter how big or small—they create a new branch. This ensures that
the master branch always contains production-quality code.
Distributed Development
 In SVN, each developer gets a working copy that points back to a single
central repository. Git, however, is a distributed version control system.
Instead of a working copy, each developer gets their own local repository,
complete with a full history of commits.
 Having a full local history makes Git fast, since it means you don’t need a
network connection to create commits, inspect previous versions of a file,
or perform diffs between commits.
 Distributed development also makes it easier to scale your engineering
team. If someone breaks the production branch in SVN, other developers
can’t check in their changes until it’s fixed. With Git, this kind of blocking
doesn’t exist. Everybody can continue going about their business in their
own local repositories.
Community
 In many circles, Git has come to be the expected version control system for
new projects. If your team is using Git, odds are you won’t have to train
new hires on your workflow, because they’ll already be familiar with
distributed development.
Install Git on Windows
 Git for Windows stand-alone installer
 Download the latest Git for Windows installer.
 When you've successfully started the installer, you should see the Git
Setup wizard screen. Follow the Next and Finish prompts to complete the
installation. The default options are pretty sensible for most users.
 Open a Command Prompt (or Git Bash if during installation you elected not
to use Git from the Windows Command Prompt).
 Run the following commands to configure your Git username and email
using the following commands, replacing Emma's name with your own.
These details will be associated with any commits that you create:
Configure Golbal
 $ git config --global user.name "Emma Paris"
 $ git config --global user.email "eparis@atlassian.com"
Workflow of git
Git Terms
 Trees
 Tree is an object, which represents a directory. It holds blobs as well as other sub-directories. A
tree is a binary file that stores references to blobs and trees which are also named
as SHA1 hash of the tree object.
 Commits
 Commit holds the current state of the repository. A commit is also named by SHA1 hash. You
can consider a commit object as a node of the linked list. Every commit object has a pointer to
the parent commit object. From a given commit, you can traverse back by looking at the
parent pointer to view the history of the commit. If a commit has multiple parent commits, then
that particular commit has been created by merging two branches.
 Branches
 Branches are used to create another line of development. By default, Git has a master branch,
which is same as trunk in Subversion. Usually, a branch is created to work on a new feature.
Once the feature is completed, it is merged back with the master branch and we delete the
branch. Every branch is referenced by HEAD, which points to the latest commit in the branch.
Whenever you make a commit, HEAD is updated with the latest commit.
 Tags
 Tag assigns a meaningful name with a specific version in the repository. Tags are very similar to
branches, but the difference is that tags are immutable. It means, tag is a branch, which
nobody intends to modify. Once a tag is created for a particular commit, even if you create a
new commit, it will not be updated. Usually, developers create tags for product releases.
 Clone
 Clone operation creates the instance of the repository. Clone operation not only checks out
the working copy, but it also mirrors the complete repository. Users can perform many
operations with this local repository. The only time networking gets involved is when the
repository instances are being synchronized.
 Pull
 Pull operation copies the changes from a remote repository instance to a local one. The pull
operation is used for synchronization between two repository instances. This is same as the
update operation in Subversion.
 Push
 Push operation copies changes from a local repository instance to a remote one. This is used
to store the changes permanently into the Git repository. This is same as the commit operation
in Subversion.
 HEAD
 HEAD is a pointer, which always points to the latest commit in the branch. Whenever you
make a commit, HEAD is updated with the latest commit. The heads of the branches are
stored in .git/refs/heads/ directory
 Repository
 A repository contains the history, the different versions over time and all different
branches and tags. In Git each copy of the repository is a complete repository. If the
repository is not a bare repository, it allows you to checkout revisions into your working
tree and to capture changes by creating new commits. Bare repositories are only
changed by transporting changes from other repositories.
 Revision
 Represents a version of the source code. Git implements revisions as commit
objects (or short commits ). These are identified by an SHA-1 hash
 Staging area
 The staging area is the place to store changes in the working tree before the commit.
The staging area contains a snapshot of the changes in the working tree (changed or
new files) relevant to create the next commit and stores their mode (file type,
executable bit).
Setting up a repository
 What is a Git repository?
 A Git repository is a virtual storage of your project. It allows you to save
versions of your code, which you can access when needed.
 Initializing a new repository: git init
 to create a new repo, you'll use the git init s a one-time command you use
during the initial setup of a new repo. Executing this command will create a
new .git subdirectory in your current working directory. This will also create a
new master branch.
Cloning an existing repository: git clone
 If a project has already been set up in a central repository, the clone
command is the most common way for users to obtain a local
development clone. Like git init cloning is generally a one-time operation.
Once a developer has obtained a working copy, all version control
operations are managed through their local repository.
 Git clone url
 Saving changes to the repository: git add and git commit
 Now that you have a repository cloned or initialized, you can commit file
version changes to it. The following example assumes you have set up a
project at
Steps
Syncing
 git remote
 The git remote command lets you create, view, and delete connections to other
repositories. Remote connections are more like bookmarks rather than direct links
into other repositories. Instead of providing real-time access to another
repository, they serve as convenient names that can be used to reference a not-
so-convenient URL.
 For example, the following diagram shows two remote connections from your
repo into the central repo and another developer’s repo. Instead of referencing
them by their full URLs, you can pass the origin and john shortcuts to other Git
commands.
git fetch
 imports commits from a remote repository into your local repo. The resulting
commits are stored as remote branches instead of the normal local
branches that we’ve been working with. This gives you a chance to review
changes before integrating them into your copy of the project.
git pull
 Merging upstream changes into your local repository is a common task in
Git-based collaboration workflows. We already know how to do this with git
fetch followed by git merge
git push
 Pushing is how you transfer commits from your local repository to a remote
repo. It's the counterpart to git fetch but whereas fetching imports
commits to local branches, pushing exports commits to remote branches.
This has the potential to overwrite changes, so you need to be careful how
you use it. These issues are discussed below.
Git Branch
 A branch represents an independent line of development. Branches serve
as an abstraction for the edit/stage/commit process. You can think of them
as a way to request a brand new working directory, staging area, and
project history. New commits are recorded in the history for the current
branch, which
 Git branch command lets you create, list, rename, and delete branches. It
doesn’t let you switch between branches or put a forked history back
together again. For this reason results in a fork in the history of the project.
 Download TortoiseGit
 Working with tortoise
 Documentation link of it
 https://tortoisegit.org/docs/tortoisegit/
Git Tutorial: An Introduction to Version Control with Git

More Related Content

What's hot

Git the fast version control system
Git the fast version control systemGit the fast version control system
Git the fast version control systemJeroen Rosenberg
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hubJasleenSondhi
 
Git in the Enterprise: How to succeed at DevOps using Git and a monorepo
Git in the Enterprise: How to succeed at DevOps using Git and a monorepoGit in the Enterprise: How to succeed at DevOps using Git and a monorepo
Git in the Enterprise: How to succeed at DevOps using Git and a monorepoGina Bustos
 
Integrating Git, Gerrit and Jenkins/Hudson with Mylyn
Integrating Git, Gerrit and Jenkins/Hudson with MylynIntegrating Git, Gerrit and Jenkins/Hudson with Mylyn
Integrating Git, Gerrit and Jenkins/Hudson with MylynSascha Scholz
 
Whether you should migrate to git
Whether you should migrate to gitWhether you should migrate to git
Whether you should migrate to gitAmit Anand
 
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012msohn
 
Using Git/Gerrit and Jenkins to Manage the Code Review Processord
Using Git/Gerrit and Jenkins to Manage the Code Review ProcessordUsing Git/Gerrit and Jenkins to Manage the Code Review Processord
Using Git/Gerrit and Jenkins to Manage the Code Review ProcessordMarc Karasek
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseHüseyin Ergin
 
Docs or it didn’t happen
Docs or it didn’t happenDocs or it didn’t happen
Docs or it didn’t happenAll Things Open
 
Git Everyday
Git EverydayGit Everyday
Git EverydayPerforce
 
How do Centralized and Distributed Version Control Systems Impact Software Ch...
How do Centralized and Distributed Version Control Systems Impact Software Ch...How do Centralized and Distributed Version Control Systems Impact Software Ch...
How do Centralized and Distributed Version Control Systems Impact Software Ch...Caius Brindescu
 
Gerrit & Jenkins Workflow: An Integrated CI Demonstration
Gerrit & Jenkins Workflow: An Integrated CI DemonstrationGerrit & Jenkins Workflow: An Integrated CI Demonstration
Gerrit & Jenkins Workflow: An Integrated CI Demonstrationvanoorts
 
Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...fureigh
 
Git Gerrit Mit Teamforge
Git Gerrit Mit TeamforgeGit Gerrit Mit Teamforge
Git Gerrit Mit TeamforgeCollabNet
 
Git/Gerrit with TeamForge
Git/Gerrit with TeamForgeGit/Gerrit with TeamForge
Git/Gerrit with TeamForgeCollabNet
 

What's hot (20)

Git the fast version control system
Git the fast version control systemGit the fast version control system
Git the fast version control system
 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
 
Gerrit Code Review
Gerrit Code ReviewGerrit Code Review
Gerrit Code Review
 
Git in the Enterprise: How to succeed at DevOps using Git and a monorepo
Git in the Enterprise: How to succeed at DevOps using Git and a monorepoGit in the Enterprise: How to succeed at DevOps using Git and a monorepo
Git in the Enterprise: How to succeed at DevOps using Git and a monorepo
 
Integrating Git, Gerrit and Jenkins/Hudson with Mylyn
Integrating Git, Gerrit and Jenkins/Hudson with MylynIntegrating Git, Gerrit and Jenkins/Hudson with Mylyn
Integrating Git, Gerrit and Jenkins/Hudson with Mylyn
 
Whether you should migrate to git
Whether you should migrate to gitWhether you should migrate to git
Whether you should migrate to git
 
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
Large Scale Development with Git and Gerrit - EclipseCon Europe 2012
 
Version controll.pptx
Version controll.pptxVersion controll.pptx
Version controll.pptx
 
Using Git/Gerrit and Jenkins to Manage the Code Review Processord
Using Git/Gerrit and Jenkins to Manage the Code Review ProcessordUsing Git/Gerrit and Jenkins to Manage the Code Review Processord
Using Git/Gerrit and Jenkins to Manage the Code Review Processord
 
Gerrit Code Review
Gerrit Code ReviewGerrit Code Review
Gerrit Code Review
 
What is git
What is gitWhat is git
What is git
 
Software Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and EclipseSoftware Versioning with Bitbucket and Eclipse
Software Versioning with Bitbucket and Eclipse
 
Docs or it didn’t happen
Docs or it didn’t happenDocs or it didn’t happen
Docs or it didn’t happen
 
Git Everyday
Git EverydayGit Everyday
Git Everyday
 
How do Centralized and Distributed Version Control Systems Impact Software Ch...
How do Centralized and Distributed Version Control Systems Impact Software Ch...How do Centralized and Distributed Version Control Systems Impact Software Ch...
How do Centralized and Distributed Version Control Systems Impact Software Ch...
 
Gerrit & Jenkins Workflow: An Integrated CI Demonstration
Gerrit & Jenkins Workflow: An Integrated CI DemonstrationGerrit & Jenkins Workflow: An Integrated CI Demonstration
Gerrit & Jenkins Workflow: An Integrated CI Demonstration
 
Git presentation
Git presentationGit presentation
Git presentation
 
Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...Git in gear: How to track changes, travel back in time, and code nicely with ...
Git in gear: How to track changes, travel back in time, and code nicely with ...
 
Git Gerrit Mit Teamforge
Git Gerrit Mit TeamforgeGit Gerrit Mit Teamforge
Git Gerrit Mit Teamforge
 
Git/Gerrit with TeamForge
Git/Gerrit with TeamForgeGit/Gerrit with TeamForge
Git/Gerrit with TeamForge
 

Similar to Git Tutorial: An Introduction to Version Control with Git

version control system (2).pptx
version control system (2).pptxversion control system (2).pptx
version control system (2).pptxDipanshuRaj19
 
GDSC23 - Github Workshop Presentation.pptx
GDSC23 - Github Workshop Presentation.pptxGDSC23 - Github Workshop Presentation.pptx
GDSC23 - Github Workshop Presentation.pptxChitreshGyanani1
 
Git Session 2K23.pptx
Git Session 2K23.pptxGit Session 2K23.pptx
Git Session 2K23.pptxEshaan35
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hubNaveen Pandey
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)Yeasin Abedin
 
Git for developers
Git for developersGit for developers
Git for developersHacen Dadda
 
Rc094 010d-git 2 - desconocido
Rc094 010d-git 2 - desconocidoRc094 010d-git 2 - desconocido
Rc094 010d-git 2 - desconocidoLuis Bertel
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxAbelPhilipJoseph
 
Git essential training & sharing self
Git essential training & sharing selfGit essential training & sharing self
Git essential training & sharing selfChen-Tien Tsai
 
Version control with GIT
Version control with GITVersion control with GIT
Version control with GITZeeshan Khan
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Simplilearn
 

Similar to Git Tutorial: An Introduction to Version Control with Git (20)

Git hub_pptx
Git hub_pptxGit hub_pptx
Git hub_pptx
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
version control system (2).pptx
version control system (2).pptxversion control system (2).pptx
version control system (2).pptx
 
Gitting better
Gitting betterGitting better
Gitting better
 
GDSC23 - Github Workshop Presentation.pptx
GDSC23 - Github Workshop Presentation.pptxGDSC23 - Github Workshop Presentation.pptx
GDSC23 - Github Workshop Presentation.pptx
 
Git Session 2K23.pptx
Git Session 2K23.pptxGit Session 2K23.pptx
Git Session 2K23.pptx
 
Introduction to git hub
Introduction to git hubIntroduction to git hub
Introduction to git hub
 
GIT and GITHUB
GIT and GITHUBGIT and GITHUB
GIT and GITHUB
 
Git Demo
Git DemoGit Demo
Git Demo
 
Git Mastery
Git MasteryGit Mastery
Git Mastery
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)
 
Git for developers
Git for developersGit for developers
Git for developers
 
Rc094 010d-git 2 - desconocido
Rc094 010d-git 2 - desconocidoRc094 010d-git 2 - desconocido
Rc094 010d-git 2 - desconocido
 
git Introduction.pptx
git Introduction.pptxgit Introduction.pptx
git Introduction.pptx
 
git github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptxgit github PPT_GDSCIIITK.pptx
git github PPT_GDSCIIITK.pptx
 
Git essential training & sharing self
Git essential training & sharing selfGit essential training & sharing self
Git essential training & sharing self
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
Version control with GIT
Version control with GITVersion control with GIT
Version control with GIT
 
Git Series - Part 1
Git Series - Part 1 Git Series - Part 1
Git Series - Part 1
 
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
Git Tutorial For Beginners | What is Git and GitHub? | DevOps Tools | DevOps ...
 

Recently uploaded

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 

Recently uploaded (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 

Git Tutorial: An Introduction to Version Control with Git

  • 1. Git Tutorial By: Ahmed Taha Software Technical Lead
  • 2. Agenda • What is version control • Benefits of version control systems • What is Git • Distributed Development • Community • Install Git on Windows • Cloning an existing repository: git clone • Git workflow • Git terms • Setting up a repository • Git usage and commands
  • 3. What is version control  Version control systems are a category of software tools that help a software team manage changes to source code over time. Version control software keeps track of every modification to the code in a special kind of database. If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members.  Software developers working in teams are continually writing new source code and changing existing source code. The code for a project, app or software component is typically organized in a folder structure or "file tree". One developer on the team may be working on a new feature while another developer fixes an unrelated bug by changing code, each developer may make their changes in several parts of the file tree.
  • 4.  Version control helps teams solve these kinds of problems, tracking every individual change by each contributor and helping prevent concurrent work from conflicting. Changes made in one part of the software can be incompatible with those made by another developer working at the same time. This problem should be discovered and solved in an orderly manner without blocking the work of the rest of the team. Further, in all software development, any change can introduce new bugs on its own and new software can't be trusted until it's tested. So testing and development proceed together until a new version is ready.
  • 5. Benefits of version control systems  Developing software without using version control is risky, like not having backups. Version control can also enable developers to move faster and it allows software teams to preserve efficiency and agility as the team scales to include more developers.  Version Control Systems (VCS) have seen great improvements over the past few decades and some are better than others. VCS are sometimes known as SCM (Source Code Management) tools or RCS (Revision Control System). One of the most popular VCS tools in use today is called Git. Git is a Distributed VCS,
  • 6. What is Git  By far, the most widely used modern version control system in the world today is Git. Git is a mature, actively maintained open source project originally developed in 2005 by Linus Torvalds, the famous creator of the Linux operating system kernel. A staggering number of software projects rely on Git for version control, including commercial projects as well as open source. Developers who have worked with Git are well represented in the pool of available software development talent and it works well on a wide range of operating systems and IDEs (Integrated Development Environments).
  • 7. characteristics  Performance  The raw performance characteristics of Git are very strong when compared to many alternatives. Committing new changes, branching, merging and comparing past versions are all optimized for performance. The algorithms implemented inside Git take advantage of deep knowledge about common attributes of real source code file trees, how they are usually modified over time and what the access patterns are
  • 8.  Security  Git has been designed with the integrity of managed source code as a top priority. The content of the files as well as the true relationships between files and directories, versions, tags and commits, all of these objects in the Git repository are secured with a cryptographically secure hashing algorithm called SHA1. This protects the code and the change history against both accidental and malicious change and ensures that the history is fully traceable.  With Git, you can be sure you have an authentic content history of your source code.
  • 9.  Flexibility  One of Git's key design objectives is flexibility. Git is flexible in several respects: in support for various kinds of nonlinear development workflows, in its efficiency in both small and large projects and in its compatibility with many existing systems and protocols.  Git has been designed to support branching and tagging as first- class citizens (unlike SVN) and operations that affect branches and tags (such as merging or reverting) are also stored as part of the change history. Not all version control systems feature this level of tracking.
  • 10. Traceability  Traceability. Being able to trace each change made to the software and connect it to project management and bug tracking software
  • 11.  Git for developers  Feature Branch Workflow  One of the biggest advantages of Git is its branching capabilities. Unlike centralized version control systems, Git branches are cheap and easy to merge. This facilitates the feature branch workflow popular with many Git users.  Feature branches provide an isolated environment for every change to your codebase. When a developer wants to start working on something— no matter how big or small—they create a new branch. This ensures that the master branch always contains production-quality code.
  • 12. Distributed Development  In SVN, each developer gets a working copy that points back to a single central repository. Git, however, is a distributed version control system. Instead of a working copy, each developer gets their own local repository, complete with a full history of commits.  Having a full local history makes Git fast, since it means you don’t need a network connection to create commits, inspect previous versions of a file, or perform diffs between commits.  Distributed development also makes it easier to scale your engineering team. If someone breaks the production branch in SVN, other developers can’t check in their changes until it’s fixed. With Git, this kind of blocking doesn’t exist. Everybody can continue going about their business in their own local repositories.
  • 13. Community  In many circles, Git has come to be the expected version control system for new projects. If your team is using Git, odds are you won’t have to train new hires on your workflow, because they’ll already be familiar with distributed development.
  • 14. Install Git on Windows  Git for Windows stand-alone installer  Download the latest Git for Windows installer.  When you've successfully started the installer, you should see the Git Setup wizard screen. Follow the Next and Finish prompts to complete the installation. The default options are pretty sensible for most users.  Open a Command Prompt (or Git Bash if during installation you elected not to use Git from the Windows Command Prompt).  Run the following commands to configure your Git username and email using the following commands, replacing Emma's name with your own. These details will be associated with any commits that you create:
  • 15. Configure Golbal  $ git config --global user.name "Emma Paris"  $ git config --global user.email "eparis@atlassian.com"
  • 17. Git Terms  Trees  Tree is an object, which represents a directory. It holds blobs as well as other sub-directories. A tree is a binary file that stores references to blobs and trees which are also named as SHA1 hash of the tree object.  Commits  Commit holds the current state of the repository. A commit is also named by SHA1 hash. You can consider a commit object as a node of the linked list. Every commit object has a pointer to the parent commit object. From a given commit, you can traverse back by looking at the parent pointer to view the history of the commit. If a commit has multiple parent commits, then that particular commit has been created by merging two branches.  Branches  Branches are used to create another line of development. By default, Git has a master branch, which is same as trunk in Subversion. Usually, a branch is created to work on a new feature. Once the feature is completed, it is merged back with the master branch and we delete the branch. Every branch is referenced by HEAD, which points to the latest commit in the branch. Whenever you make a commit, HEAD is updated with the latest commit.  Tags  Tag assigns a meaningful name with a specific version in the repository. Tags are very similar to branches, but the difference is that tags are immutable. It means, tag is a branch, which nobody intends to modify. Once a tag is created for a particular commit, even if you create a new commit, it will not be updated. Usually, developers create tags for product releases.
  • 18.  Clone  Clone operation creates the instance of the repository. Clone operation not only checks out the working copy, but it also mirrors the complete repository. Users can perform many operations with this local repository. The only time networking gets involved is when the repository instances are being synchronized.  Pull  Pull operation copies the changes from a remote repository instance to a local one. The pull operation is used for synchronization between two repository instances. This is same as the update operation in Subversion.  Push  Push operation copies changes from a local repository instance to a remote one. This is used to store the changes permanently into the Git repository. This is same as the commit operation in Subversion.  HEAD  HEAD is a pointer, which always points to the latest commit in the branch. Whenever you make a commit, HEAD is updated with the latest commit. The heads of the branches are stored in .git/refs/heads/ directory
  • 19.  Repository  A repository contains the history, the different versions over time and all different branches and tags. In Git each copy of the repository is a complete repository. If the repository is not a bare repository, it allows you to checkout revisions into your working tree and to capture changes by creating new commits. Bare repositories are only changed by transporting changes from other repositories.  Revision  Represents a version of the source code. Git implements revisions as commit objects (or short commits ). These are identified by an SHA-1 hash  Staging area  The staging area is the place to store changes in the working tree before the commit. The staging area contains a snapshot of the changes in the working tree (changed or new files) relevant to create the next commit and stores their mode (file type, executable bit).
  • 20. Setting up a repository  What is a Git repository?  A Git repository is a virtual storage of your project. It allows you to save versions of your code, which you can access when needed.  Initializing a new repository: git init  to create a new repo, you'll use the git init s a one-time command you use during the initial setup of a new repo. Executing this command will create a new .git subdirectory in your current working directory. This will also create a new master branch.
  • 21. Cloning an existing repository: git clone  If a project has already been set up in a central repository, the clone command is the most common way for users to obtain a local development clone. Like git init cloning is generally a one-time operation. Once a developer has obtained a working copy, all version control operations are managed through their local repository.  Git clone url  Saving changes to the repository: git add and git commit  Now that you have a repository cloned or initialized, you can commit file version changes to it. The following example assumes you have set up a project at
  • 22. Steps
  • 23. Syncing  git remote  The git remote command lets you create, view, and delete connections to other repositories. Remote connections are more like bookmarks rather than direct links into other repositories. Instead of providing real-time access to another repository, they serve as convenient names that can be used to reference a not- so-convenient URL.  For example, the following diagram shows two remote connections from your repo into the central repo and another developer’s repo. Instead of referencing them by their full URLs, you can pass the origin and john shortcuts to other Git commands.
  • 24.
  • 25. git fetch  imports commits from a remote repository into your local repo. The resulting commits are stored as remote branches instead of the normal local branches that we’ve been working with. This gives you a chance to review changes before integrating them into your copy of the project.
  • 26. git pull  Merging upstream changes into your local repository is a common task in Git-based collaboration workflows. We already know how to do this with git fetch followed by git merge
  • 27. git push  Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch but whereas fetching imports commits to local branches, pushing exports commits to remote branches. This has the potential to overwrite changes, so you need to be careful how you use it. These issues are discussed below.
  • 28.
  • 29. Git Branch  A branch represents an independent line of development. Branches serve as an abstraction for the edit/stage/commit process. You can think of them as a way to request a brand new working directory, staging area, and project history. New commits are recorded in the history for the current branch, which  Git branch command lets you create, list, rename, and delete branches. It doesn’t let you switch between branches or put a forked history back together again. For this reason results in a fork in the history of the project.
  • 30.
  • 31.
  • 32.  Download TortoiseGit  Working with tortoise  Documentation link of it  https://tortoisegit.org/docs/tortoisegit/