0% found this document useful (0 votes)
73 views41 pages

Session 02 - Git Presentation

The document provides an overview of version control and the Git version control system, explaining what version control is, the basics of how Git works, including tracking changes, commits, branches, merging, and resolving conflicts. It also covers setting up Git locally and with remote repositories like GitHub, as well as installing and using Git through various clients and platforms.

Uploaded by

Kosmas Stamos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views41 pages

Session 02 - Git Presentation

The document provides an overview of version control and the Git version control system, explaining what version control is, the basics of how Git works, including tracking changes, commits, branches, merging, and resolving conflicts. It also covers setting up Git locally and with remote repositories like GitHub, as well as installing and using Git through various clients and platforms.

Uploaded by

Kosmas Stamos
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 41

VERSION

CONTROL
WITH GIT
Kostas Sofos
INTRO
Subjects

• What is Version Control?


• What is Git
• Git Basics
• Git Remotes
• Hands-On
WHAT IS VERSION CONTROL?
VERSION CONTROL SYSTEM
What?

• Also known as a source code manager (SCM)

• A system that maintains a history of all changes made to the


code

• In case of any problems, lets you go back in time and revert


to a working state of your source code
VERSION CONTROL SYSTEM
What?

• Helps developers move faster and allows software teams to


preserve efficiency and agility as the team scales up

• Version control is independent of the kind of project /


technology / framework you're working with

• Centralized / Distributed
VERSION CONTROL SYSTEM
Centralized

• In a centralized Version Control System, a


server acts as the main repository which stores
every version of code
• Every user commits directly to the main branch
VERSION CONTROL SYSTEM
Centralized - Pros

• Works well with binary files

• Offers full visibility in Project state

• Small learning curve


VERSION CONTROL SYSTEM
Centralized - Cons

• A single point of failure risks data

• Slow speed delays development

• Few stable moments to push changes


VERSION CONTROL SYSTEM
Distributed

• Instead of one single repository which


is the server, here every single
developer has a copy of the entire
history in their machine
VERSION CONTROL SYSTEM
Distributed - Pros

• Fast

• Works offline

• Cheap branching and merging

• Easy to scale

• Ability to push changes continuously

• Open source
VERSION CONTROL SYSTEM
Distributed - Cons

• Large binary files that are difficult to compress, will

occupy more space

• Not having a central server might cause confusions in

identifying the right recent version


VERSION CONTROL SYSTEM
Why?

Project
Developer A Developer B

Initiate Contribute
VERSION CONTROL SYSTEM
Why?
Developer D Developer C

Proj_1eleven11one.zip
Project Proj_new.zip
Developer A Developer B

Proj_newer.zip
Proj_1one1.zip

Proj.zip
Proj_1.zip
WHAT IS GIT
GIT
What?

• Distributed version control software

• Fast

• Free

• Cross platform

• Open-source

• Created by Linus Torvalds in 2005


GIT
Features

• Tracking the changes and updates. We are able to see who


made which changes

• Provides when and why a change was made

• Allowing to work collaboratively

• Focus on the project instead of extensive communication


sessions
GIT BASICS
GIT BASICS
Git clients

• Visual Studio

• Vs Code

• SourceTree

• GitKraken

• SmartGit

• Fork
GIT BASICS
Fundamental elements
GIT LOCAL REPOS

• Git local repository is the one on which we will


make local changes, typically this local
repository is on our computer.
GIT REMOTE REPOS

• Remote repositories are versions of your


project that are hosted on the Internet or
another network

• You can have several of them, each of


which generally is either read-only or
read/write for you
GITHUB

• Free

• Public – Private repositories

• Offers a cloud-based Git repository hosting service

• Interface is user-friendly enough so even novice coders can


take advantage of Git

• So user-friendly that some people even use it to manage


other types of projects like writing books
GIT BASICS
Setting up a repo – Git Init

• Creates a new Git repository


• Used to convert an existing, unversioned
project to a Git repository or initialize a
new, empty repository.
• Most other Git commands are not
available outside of an initialized
repository
GIT BASICS
Setting up a repo – Git Clone

• Used to target an existing repository and


create a clone, or copy of the target
remote repository
GIT BASICS
Git Add

• Used to add a file that is in the


working directory to the staging area
GIT BASICS
Git Commit

• Used to add all files that are staged to


the local repository
GIT BASICS
Git Push

• Used to add all committed files in the


local repository to the remote
repository
GIT BASICS
Git Fetch

• Used to get files from the remote


repository to the local repository but
not into the working directory
GIT BASICS
Git Merge

• Used to get the files from the local


repository into the working directory
GIT BASICS
Git Pull

• Used to get files from the remote


repository directly into the working
directory. It is equivalent to a git fetch
and a git merge
GIT BASICS
Commit

• Git takes a snapshot of the project and stores it in the


repository along with some other identifying information

• The commit object contains information about the


directory tree object hash, parent commit hash, author,
committer, date and message
• Each time we commit, Git records the information
above. Thus, we have a highly useful history of the
project.
GIT BASICS
Branches

• “Simply” a lightweight movable pointer to


one of the commits

• Think of branches as a way to work on


your project by adding a new feature of
bug fixes without affecting the master
branch
GIT BASICS
Collaborating / Merge

• Git merging combines sequences of


commits into one unified history
of commits
• Git can automatically merge commits
unless there are changes that conflict in
both commit sequences
GIT BASICS
Merge Conflicts

• Git can automatically merge commits


unless there are changes that conflict in
both commit sequences
• Conflicts generally arise when two people
have changed the same lines in a file, or if
one developer deleted a file while another
developer was modifying it
GIT BASICS
Merge Conflicts

• Git can automatically merge commits


unless there are changes that conflict in
both commit sequences
• Conflicts generally arise when two people
have changed the same lines in a file, or if
one developer deleted a file while another
developer was modifying it
GIT BASICS
Merge Conflict Resolution

Commit B (NewFeature)

Commit A (master)

merge

Commit C (master)
GIT BASICS
Merge Conflict Resolution

Vs Code Visual Studio


INSTALLATION
INSTALLATION

Download Git
https://git-scm.com
USEFUL LINKS

• Git https://git-scm.com

• GitHub https://github.com
HANDS ON

You might also like