SlideShare ist ein Scribd-Unternehmen logo
1 von 16
VERSION CONTROL WITH
GIT
-BY SAHIL AGARWAL
ASU2014030100143
ABOUT VERSION CONTROL
What is "version control", and why should you
care?
Version control is a system that records changes to a file or set of files over time so
that you can recall specific versions later.
A Version Control System (VCS) allows you to revert files back to a previous state,
revert the entire project back to a previous state, compare changes over time, see who last
modified something that might be causing a problem, who introduced an issue and when,
and more. Using a VCS also generally means that if lose files, you can easily recover. In
addition, you get all this for very little overhead.
ABOUT VERSION CONTROL
Local Version Control Systems
Many people’s version-control method of choice is to copy files into another
directory (perhaps a time-stamped directory, if they’re clever). This approach is very
common because it is so simple, but it is also incredibly error prone.
It is easy to forget which directory you’re in and accidentally write to the wrong file or
copy over files you don’t mean to.
ABOUT VERSION CONTROL
This setup offers many advantages, especially over local VCSs.
• Everyone knows to a certain degree what everyone else on the project is doing.
• Administrators have fine-grained control over who can do what; and it’s far easier to administer
a CVCS than it is to deal with local databases on every client.
However, this setup also has some serious downsides.
• If that server goes down for an hour, then during that hour nobody can collaborate at all or save
versioned changes to anything they’re working on.
• If the hard disk the central database is on becomes corrupted, and proper backups haven’t been
kept, you lose absolutely everything – the entire history of the project except whatever single
snapshots people happen to have on their local machines. Local VCS systems suffer from this
same problem – whenever you have the entire history of the project in a single place, you risk
losing everything.
Centralized Version Control Systems
CVCSs were developed to collaborate with developers on other
systems. These systems, such as CVS, Subversion, and Perforce,
have a single server that contains all the versioned files, and a
number of clients that check out files from that central place.
Distributed Version Control Systems
In a DVCS (such as Git, Mercurial, Bazaar or Darcs), clients
don’t just check out the latest snapshot of the files: they fully
mirror the repository. Thus if any server dies, and these
systems were collaborating via it, any of the client repositories
can be copied back up to the server to restore it. Every clone is
really a full backup of all the data.
Furthermore, many of these systems deal pretty well with
having several remote repositories they can work with, so you
can collaborate with different groups of people in different
ways simultaneously within the same project. This allows you
to set up several types of workflows that aren’t possible in
centralized systems, such as hierarchical models.
ABOUT VERSION CONTROL
WHAT IS GIT?
• Developed in 2005 by the Linux Development community after the
DVCS BitKeeper’s free-of-charge status was revoked.
• Some of the goals during the system development were – speed,
simple design, strong support for branched development, fully
distributed, able to handle large projects efficiently.
• Git is a Distributed Version Control System.
• Free and Open Source - Git is released under the GNU General Public
License version 2.0, which is an open source license.
WHY GIT?
Conceptually, most
other systems store
information as a list
of file-based
changes. These
systems think of
the information
they keep as a set
of files and the
changes made to
The major difference between Git and any other VCS is the way Git
thinks about its data.
• Git thinks of its data
more like a set of
snapshots of a
miniature filesystem.
• Every time you commit,
or save the state of your
project
WHY GIT?
in Git, it basically takes a picture of what all your files look like at
that moment and stores a reference to that snapshot. To be
efficient, if files have not changed, Git doesn’t store the file again,
just a link to the previous identical file it has already stored.
Git thinks about its data more like a stream of snapshots.
GIT BASICS Git Has Integrity
Everything in Git is check-summed before it is
stored and is then referred to by that
checksum. This means it’s impossible to
change the contents of any file or directory
without Git knowing about it. This functionality
is built into Git at the lowest levels and is
integral to its philosophy. You can’t lose
information in transit or get file corruption
without Git being able to detect it.
Nearly Every Operation Is
Local
Most operations in Git only need
local files and resources to
operate – generally no
information is needed from
another computer on your
network Because you have the
entire history of the project right
there on your local disk, most
operations seem almost
instantaneous. This also means
that there is very little you can’t
Git Generally Only Adds Data
When you do actions in Git, nearly all of them
only add data to the Git database. As in any
VCS, you can lose or mess up changes you
haven’t committed yet; but after you commit a
snapshot into Git, it is very difficult to lose,
especially if you regularly push your database
to another repository.
GIT BASICS - THE THREE STATES
This leads us to the three
main sections of a Git project:
the Git directory, the working
directory, and the staging
area.
Git has three main states that your files can reside in: 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.
The Git directory is where Git stores the metadata and object database for your project. This is
the most important part of Git, and it is what is copied when you clone a repository from another
computer.
The working directory is a single checkout of one version of the project. These files are
pulled out of the compressed database in the Git directory and placed on disk for you to use or
modify.
The staging area is a file, generally contained in your Git directory, that stores information
about what will go into your next commit. It’s sometimes referred to as the “index”, but it’s also
common to refer to it as the staging area.
The basic Git workflow:
You modify files in your working directory.
You stage the files, adding snapshots of them to your staging area.
You do a commit, which takes the files as they are in the staging area and stores that snapshot
permanently to your Git directory ie. Head.
If a particular version of a file is in the Git directory, it’s considered committed. If it has been modified
GIT BASICS - WORKFLOW
This allows you to stage only portions of a modified file. You can just stage the
change you need for the current commit and stage the other change for the next
commit. This feature scales up to as many different changes to your file as
needed.
GIT BASICS - STAGING AREA
The "staging area" or "index“ is an intermediate area where commits can be
formatted and reviewed before completing the commit.
One thing that sets Git apart from
other tools is that it's possible to
quickly stage some of your files
and commit them without
committing all of the other
modified files in your working
directory or having to list them on
the command line during the
commit.
GIT BASICS
Branching
Branches are used to develop features isolated from each other. The
master branch is the "default" branch when you create a repository. Use other
branches for development and merge them back to the master branch upon
completion.
A branch is not available to others unless you push the branch to your
remote repository
Tagging
It is recommended to create tags for software releases. This is a known
concept, which also exists in SVN.
Log
You can study repository history using log. You can add a lot of parameters
to make the log look like what you want.
There are a lot of different ways to use Git. There are the original
command line tools, and there are many graphical user interfaces of
varying capabilities.
The command line is the only place you can run all Git commands –
most of the GUIs only implement some subset of Git functionality for
simplicity. If you know how to run the command line version, you can
probably also figure out how to run the GUI version, while the opposite
is not necessarily true. Also, while your choice of graphical client is a
matter of personal taste, all users will have the command-line tools
installed and available.
GIT BASICS - THE COMMAND LINE
BASIC GIT COMMANDS
1. Create a new repository
1. git init
2. Checkout a repository
1. git clone /path/to/repository
2. git clone
username@host:/path/to/reposit
ory
3. Add & Commit
1. git add <filename>
2. git add *
3. git commit -m "Commit
message"
4. Pushing Changes
1. git push origin master
6. Branching and Switching
1. git checkout -b feature_x
2. git checkout master
3. git branch -d feature_x
4. git push origin <branch>
7. Update & Merge
1. git pull
2. git merge <branch>
3. git add <filename>
4. git diff <source_branch>
<target_branch>
8. Tagging
1. git tag 1.0.0 1b2e1d63ff
9. Log
1. git log
2. git log --author=bob
3. git log --pretty=oneline
4. git log --name-status
5. git log --help
THANK YOU

Weitere ähnliche Inhalte

Was ist angesagt?

git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
azwildcat
 

Was ist angesagt? (20)

Git
GitGit
Git
 
Techoalien git
Techoalien gitTechoalien git
Techoalien git
 
git-and-bitbucket
git-and-bitbucketgit-and-bitbucket
git-and-bitbucket
 
Git Workflow
Git WorkflowGit Workflow
Git Workflow
 
Git SVN Migrate Reasons
Git SVN Migrate ReasonsGit SVN Migrate Reasons
Git SVN Migrate Reasons
 
Version control git day01
Version control   git day01Version control   git day01
Version control git day01
 
git Versioning
git Versioninggit Versioning
git Versioning
 
Game Programming - Git
Game Programming - GitGame Programming - Git
Game Programming - Git
 
Game Programming 03 - Git Flow
Game Programming 03 - Git FlowGame Programming 03 - Git Flow
Game Programming 03 - Git Flow
 
Introduction to Git
Introduction to GitIntroduction to Git
Introduction to Git
 
Tool Development A - Git
Tool Development A - GitTool Development A - Git
Tool Development A - Git
 
Using GIT for Everyone
Using GIT for EveryoneUsing GIT for Everyone
Using GIT for Everyone
 
Roslyn on GitHub
Roslyn on GitHubRoslyn on GitHub
Roslyn on GitHub
 
Git with bitbucket
Git with bitbucketGit with bitbucket
Git with bitbucket
 
Git Tutorial
Git TutorialGit Tutorial
Git Tutorial
 
Version Control System (Rajab DAVUDOV)
Version Control System (Rajab DAVUDOV)Version Control System (Rajab DAVUDOV)
Version Control System (Rajab DAVUDOV)
 
Whether you should migrate to git
Whether you should migrate to gitWhether you should migrate to git
Whether you should migrate to git
 
The Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHubThe Basics of Open Source Collaboration With Git and GitHub
The Basics of Open Source Collaboration With Git and GitHub
 
Git basics
Git basicsGit basics
Git basics
 
Introducing to git
Introducing to gitIntroducing to git
Introducing to git
 

Andere mochten auch

Tk6 Movelist
Tk6 MovelistTk6 Movelist
Tk6 Movelist
guest3f71
 
resume new healthcare 2016 international
resume new healthcare 2016 internationalresume new healthcare 2016 international
resume new healthcare 2016 international
Kayla Walker
 
12632_CSAsphalt_Enfield_Terminal_LR
12632_CSAsphalt_Enfield_Terminal_LR12632_CSAsphalt_Enfield_Terminal_LR
12632_CSAsphalt_Enfield_Terminal_LR
Andrew de Villiers
 

Andere mochten auch (20)

HTTP request and response
HTTP request and responseHTTP request and response
HTTP request and response
 
Mang May Tinh
Mang May TinhMang May Tinh
Mang May Tinh
 
ICMP-Học viện Kỹ thuật Mật mã
ICMP-Học viện Kỹ thuật Mật mãICMP-Học viện Kỹ thuật Mật mã
ICMP-Học viện Kỹ thuật Mật mã
 
Placabase amayalazaro
Placabase amayalazaroPlacabase amayalazaro
Placabase amayalazaro
 
MiaWest
MiaWestMiaWest
MiaWest
 
Tk6 Movelist
Tk6 MovelistTk6 Movelist
Tk6 Movelist
 
resume new healthcare 2016 international
resume new healthcare 2016 internationalresume new healthcare 2016 international
resume new healthcare 2016 international
 
Criarts
CriartsCriarts
Criarts
 
Proyecto saia (terminado)
Proyecto saia (terminado)Proyecto saia (terminado)
Proyecto saia (terminado)
 
12632_CSAsphalt_Enfield_Terminal_LR
12632_CSAsphalt_Enfield_Terminal_LR12632_CSAsphalt_Enfield_Terminal_LR
12632_CSAsphalt_Enfield_Terminal_LR
 
SLII Membership
SLII MembershipSLII Membership
SLII Membership
 
Michael Yakushev - ICANN accountability and IANA transition - ArmIGF2015
Michael Yakushev - ICANN accountability and IANA transition - ArmIGF2015Michael Yakushev - ICANN accountability and IANA transition - ArmIGF2015
Michael Yakushev - ICANN accountability and IANA transition - ArmIGF2015
 
Day 2 Bob Ochieng - ICANN - IANA Transition
Day 2  Bob Ochieng - ICANN - IANA TransitionDay 2  Bob Ochieng - ICANN - IANA Transition
Day 2 Bob Ochieng - ICANN - IANA Transition
 
Internet protocols
Internet protocolsInternet protocols
Internet protocols
 
ICANN 51: IANA Department – Who, What, Why?"
ICANN 51: IANA Department – Who, What, Why?"ICANN 51: IANA Department – Who, What, Why?"
ICANN 51: IANA Department – Who, What, Why?"
 
Photo realism22
Photo realism22Photo realism22
Photo realism22
 
Jetty 9 – The Next Generation Servlet Container
Jetty 9 – The Next Generation Servlet ContainerJetty 9 – The Next Generation Servlet Container
Jetty 9 – The Next Generation Servlet Container
 
The IANA Functions
The IANA FunctionsThe IANA Functions
The IANA Functions
 
Network
NetworkNetwork
Network
 
Treatment for tv advert
Treatment for tv advertTreatment for tv advert
Treatment for tv advert
 

Ähnlich wie Version Control with Git

Svn vs mercurial vs github
Svn  vs  mercurial vs  githubSvn  vs  mercurial vs  github
Svn vs mercurial vs github
Vinoth Kannan
 

Ähnlich wie Version Control with Git (20)

Introduction to Git and GitHub
Introduction to Git and GitHubIntroduction to Git and GitHub
Introduction to Git and GitHub
 
Git 101
Git 101Git 101
Git 101
 
Svn vs mercurial vs github
Svn  vs  mercurial vs  githubSvn  vs  mercurial vs  github
Svn vs mercurial vs github
 
Git Tutorial
Git Tutorial Git Tutorial
Git Tutorial
 
Git Training
Git TrainingGit Training
Git Training
 
GIT_Overview.
GIT_Overview.GIT_Overview.
GIT_Overview.
 
Mini-training: Let’s Git It!
Mini-training: Let’s Git It!Mini-training: Let’s Git It!
Mini-training: Let’s Git It!
 
Git Series - Part 1
Git Series - Part 1 Git Series - Part 1
Git Series - Part 1
 
Version Control Systems -- Git -- Part I
Version Control Systems -- Git -- Part IVersion Control Systems -- Git -- Part I
Version Control Systems -- Git -- Part I
 
Git session 1
Git session 1Git session 1
Git session 1
 
version control system (2).pptx
version control system (2).pptxversion control system (2).pptx
version control system (2).pptx
 
Git Mastery
Git MasteryGit Mastery
Git Mastery
 
Introduction to GIT Endava 2023
Introduction to GIT Endava 2023Introduction to GIT Endava 2023
Introduction to GIT Endava 2023
 
GIT INTRODUCTION
GIT INTRODUCTIONGIT INTRODUCTION
GIT INTRODUCTION
 
Git
GitGit
Git
 
Git usage (Basics and workflow)
Git usage (Basics and workflow)Git usage (Basics and workflow)
Git usage (Basics and workflow)
 
git and github-1.pptx
git and github-1.pptxgit and github-1.pptx
git and github-1.pptx
 
Git introduction
Git introductionGit introduction
Git introduction
 
Git for developers
Git for developersGit for developers
Git for developers
 
1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx1-Intro to VC & GIT PDF.pptx
1-Intro to VC & GIT PDF.pptx
 

Version Control with Git

  • 1. VERSION CONTROL WITH GIT -BY SAHIL AGARWAL ASU2014030100143
  • 2. ABOUT VERSION CONTROL What is "version control", and why should you care? Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. A Version Control System (VCS) allows you to revert files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Using a VCS also generally means that if lose files, you can easily recover. In addition, you get all this for very little overhead.
  • 3. ABOUT VERSION CONTROL Local Version Control Systems Many people’s version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they’re clever). This approach is very common because it is so simple, but it is also incredibly error prone. It is easy to forget which directory you’re in and accidentally write to the wrong file or copy over files you don’t mean to.
  • 4. ABOUT VERSION CONTROL This setup offers many advantages, especially over local VCSs. • Everyone knows to a certain degree what everyone else on the project is doing. • Administrators have fine-grained control over who can do what; and it’s far easier to administer a CVCS than it is to deal with local databases on every client. However, this setup also has some serious downsides. • If that server goes down for an hour, then during that hour nobody can collaborate at all or save versioned changes to anything they’re working on. • If the hard disk the central database is on becomes corrupted, and proper backups haven’t been kept, you lose absolutely everything – the entire history of the project except whatever single snapshots people happen to have on their local machines. Local VCS systems suffer from this same problem – whenever you have the entire history of the project in a single place, you risk losing everything. Centralized Version Control Systems CVCSs were developed to collaborate with developers on other systems. These systems, such as CVS, Subversion, and Perforce, have a single server that contains all the versioned files, and a number of clients that check out files from that central place.
  • 5. Distributed Version Control Systems In a DVCS (such as Git, Mercurial, Bazaar or Darcs), clients don’t just check out the latest snapshot of the files: they fully mirror the repository. Thus if any server dies, and these systems were collaborating via it, any of the client repositories can be copied back up to the server to restore it. Every clone is really a full backup of all the data. Furthermore, many of these systems deal pretty well with having several remote repositories they can work with, so you can collaborate with different groups of people in different ways simultaneously within the same project. This allows you to set up several types of workflows that aren’t possible in centralized systems, such as hierarchical models. ABOUT VERSION CONTROL
  • 6. WHAT IS GIT? • Developed in 2005 by the Linux Development community after the DVCS BitKeeper’s free-of-charge status was revoked. • Some of the goals during the system development were – speed, simple design, strong support for branched development, fully distributed, able to handle large projects efficiently. • Git is a Distributed Version Control System. • Free and Open Source - Git is released under the GNU General Public License version 2.0, which is an open source license.
  • 7. WHY GIT? Conceptually, most other systems store information as a list of file-based changes. These systems think of the information they keep as a set of files and the changes made to The major difference between Git and any other VCS is the way Git thinks about its data.
  • 8. • Git thinks of its data more like a set of snapshots of a miniature filesystem. • Every time you commit, or save the state of your project WHY GIT? in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshot. To be efficient, if files have not changed, Git doesn’t store the file again, just a link to the previous identical file it has already stored. Git thinks about its data more like a stream of snapshots.
  • 9. GIT BASICS Git Has Integrity Everything in Git is check-summed before it is stored and is then referred to by that checksum. This means it’s impossible to change the contents of any file or directory without Git knowing about it. This functionality is built into Git at the lowest levels and is integral to its philosophy. You can’t lose information in transit or get file corruption without Git being able to detect it. Nearly Every Operation Is Local Most operations in Git only need local files and resources to operate – generally no information is needed from another computer on your network Because you have the entire history of the project right there on your local disk, most operations seem almost instantaneous. This also means that there is very little you can’t Git Generally Only Adds Data When you do actions in Git, nearly all of them only add data to the Git database. As in any VCS, you can lose or mess up changes you haven’t committed yet; but after you commit a snapshot into Git, it is very difficult to lose, especially if you regularly push your database to another repository.
  • 10. GIT BASICS - THE THREE STATES This leads us to the three main sections of a Git project: the Git directory, the working directory, and the staging area. Git has three main states that your files can reside in: 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.
  • 11. The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer. The working directory is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify. The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the “index”, but it’s also common to refer to it as the staging area. The basic Git workflow: You modify files in your working directory. You stage the files, adding snapshots of them to your staging area. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory ie. Head. If a particular version of a file is in the Git directory, it’s considered committed. If it has been modified GIT BASICS - WORKFLOW
  • 12. This allows you to stage only portions of a modified file. You can just stage the change you need for the current commit and stage the other change for the next commit. This feature scales up to as many different changes to your file as needed. GIT BASICS - STAGING AREA The "staging area" or "index“ is an intermediate area where commits can be formatted and reviewed before completing the commit. One thing that sets Git apart from other tools is that it's possible to quickly stage some of your files and commit them without committing all of the other modified files in your working directory or having to list them on the command line during the commit.
  • 13. GIT BASICS Branching Branches are used to develop features isolated from each other. The master branch is the "default" branch when you create a repository. Use other branches for development and merge them back to the master branch upon completion. A branch is not available to others unless you push the branch to your remote repository Tagging It is recommended to create tags for software releases. This is a known concept, which also exists in SVN. Log You can study repository history using log. You can add a lot of parameters to make the log look like what you want.
  • 14. There are a lot of different ways to use Git. There are the original command line tools, and there are many graphical user interfaces of varying capabilities. The command line is the only place you can run all Git commands – most of the GUIs only implement some subset of Git functionality for simplicity. If you know how to run the command line version, you can probably also figure out how to run the GUI version, while the opposite is not necessarily true. Also, while your choice of graphical client is a matter of personal taste, all users will have the command-line tools installed and available. GIT BASICS - THE COMMAND LINE
  • 15. BASIC GIT COMMANDS 1. Create a new repository 1. git init 2. Checkout a repository 1. git clone /path/to/repository 2. git clone username@host:/path/to/reposit ory 3. Add & Commit 1. git add <filename> 2. git add * 3. git commit -m "Commit message" 4. Pushing Changes 1. git push origin master 6. Branching and Switching 1. git checkout -b feature_x 2. git checkout master 3. git branch -d feature_x 4. git push origin <branch> 7. Update & Merge 1. git pull 2. git merge <branch> 3. git add <filename> 4. git diff <source_branch> <target_branch> 8. Tagging 1. git tag 1.0.0 1b2e1d63ff 9. Log 1. git log 2. git log --author=bob 3. git log --pretty=oneline 4. git log --name-status 5. git log --help