Git GitHub

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 26

Git & GitHub

Git
Git is a popular version control system. It was
created by Linus Torvalds in 2005, and has
been maintained by Junio Hamano since then.
It is used for:
• Tracking code changes
• Tracking who made changes
• Coding collaboration
Features
1. Distributed
2. Compatiable
3. Non-Linear
4. Lightweight
5. Speed
6. Open Source
7. Reliable
8. Secure
What does Git do?

• Manage projects with Repositories


• Clone a project to work on a local copy
• Control and track changes
with Staging and Committing
• Branch and Merge to allow for work on
different parts and versions of a project
• Pull the latest version of the project to a local
copy
• Push local updates to the main project
Working with Git

• Initialize Git on a folder, making it a Repository


• Git now creates a hidden folder to keep track of changes
in that folder
• When a file is changed, added or deleted, it is
considered modified
• You select the modified files you want to Stage
• The Staged files are Committed, which prompts Git to
store a permanent snapshot of the files
• Git allows you to see the full history of every commit.
• You can revert back to any previous commit.
Why Git?

• Over 70% of developers use Git!


• Developers can work together from anywhere
in the world.
• Developers can see the full history of the
project.
• Developers can revert to earlier versions of a
project.
What is GitHub?

• Git is not the same as GitHub.


• GitHub makes tools that use Git.
• GitHub is the largest host of source code in
the world, and has been owned by Microsoft
since 2018.
Git – Life Cycle

Git is used in our day-to-day work, we use git


for keeping a track of our files, working in a
collaboration with our team, to go back to our
previous code versions if we face some error.
Git helps us in many ways.
• Step–1, We first clone any of the code residing in
the remote repository to make our own local
repository.
• Step-2 we edit the files that we have cloned in
our local repository and make the necessary
changes in it.
• Step-3 we commit our changes by first adding
them to our staging area and committing them
with a commit message.
• Step – 4 and Step-5 we first check whether
there are any of the changes done in the
remote repository by some other users and we
first pull that changes.
• If there are no changes we directly proceed
with Step – 6 in which we push our changes to
the remote repository and we are done with
our work.
• When a directory is made a git repository,
there are mainly 3 states which make the
essence of Git Version Control System. The
three states are –
• Working Directory
• Staging Area
• Git Directory
Working Directory

• Whenever we want to initialize our local


project directory to make it a git repository,
we use the git init command. After this
command, git becomes aware of the files in
the project although it doesn’t track the files
yet. The files are further tracked in the staging
area.
• git init
Staging Area

• Now, to track the different versions of our files we use the


command git add.
• We can term a staging area as a place where different versions of
our files are stored. git add command copies the version of your
file from your working directory to the staging area.
• We can, however, choose which files we need to add to the
staging area because in our working directory there are some
files that we don’t want to get tracked.
• // to specify which file to add to the staging area
• git add <filename>
• // to add all files of the working directory to the staging area
• git add .
Git Directory

• Now since we have all the files that are to be tracked and are ready in
the staging area, we are ready to commit our files using the git
commit command.
• Commit helps us in keeping the track of the metadata of the files in
our staging area.
• We specify every commit with a message which tells what the commit
is about. Git preserves the information or the metadata of the files
that were committed in a Git Directory which helps Git in tracking files
and basically it preserves the photocopy of the committed files.
• Commit also stores the name of the author who did the commit, files
that are committed, and the date at which they are committed along
with the commit message.
• git commit -m <Commit Message>
Git Version Control System

• A version control system is a software that tracks


changes to a file or set of files over time so that you
can recall specific versions later. It also allows you to
work together with other programmers.
• The version control system is a collection of software
tools that help a team to manage changes in a
source code. It uses a special kind of database to
keep track of every modification to the code.
• Developers can compare earlier versions of the code
with an older version to fix the mistakes.
Benefits of the Version Control System

The Version Control System is very helpful and


beneficial in software development;
developing software without using version
control is unsafe. It provides backups for
uncertainty. Version control systems offer a
speedy interface to developers. It also allows
software teams to preserve efficiency and
agility according to the team scales to include
more developers.
Some key benefits of having a version control system are as follows.

• Complete change history of the file


• Simultaneously working
• Branching and merging
• Traceability
Types of Version Control System

• Localized version Control System


• Centralized version control systems
Localized Version Control Systems
Centralized Version Control System

You might also like