0% found this document useful (0 votes)
3 views

Git Basics

Version control is a system that tracks changes to files over time, allowing users to revert to previous versions and collaborate effectively. Git is a widely used distributed version control system that enables branching and merging as part of daily workflows, distinguishing itself from centralized systems. Users can manage local repositories and share their work through remote hosting services like GitHub.

Uploaded by

Mehedi Hasan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Git Basics

Version control is a system that tracks changes to files over time, allowing users to revert to previous versions and collaborate effectively. Git is a widely used distributed version control system that enables branching and merging as part of daily workflows, distinguishing itself from centralized systems. Users can manage local repositories and share their work through remote hosting services like GitHub.

Uploaded by

Mehedi Hasan
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Version Control with git

Version Control
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.

Version control is like a big undo button for your project. It 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 you
screw things up or lose files, you can easily recover.
What is version control?
• Management of changes to documents over time
• Text documents in general
• Program source code and documentation
• Simple version control
• Multiple copies of the files labeled with (revision) numbers or dates
(timestamp)
• Requires discipline from the programmers
• Other names
• Revision control
• Source control
• Version management system
Version control, using Git 3
Examples
Version control is most commonly realized with stand-alone
applications such as git or svn but is also embedded in various types of
software such as Google docs and Wikipedia (page history).
Categories of Version Control
Systems
The two main categories of version control systems are centralized (e.g.
subversion or svn) and decentralized or distributed (e.g. git). With a
centralized system the repository is located in one place. With a
distributed system each user has a copy of the repository.

Centralized Distributed
Version Control Collaboration Models
• The main function of a version control system is to allow collaborative
editing and sharing of data.
• There are two main strategies for enabling this:
• Lock-Modify-Unlock (aka reserved checkout)
• Copy-Modify-Merge (aka unreserved checkout or optimistic checkout)
Lock-Modify-Unlock
Copy-Modify-Merge
Version control:
Some important concepts
• Repository
• The documents are kept in a repository
• Repository can be either central or distributed
• Check out
• To modify the documents you must check out the documents from the
repository.
• You get a local copy, called ”working copy”
• Check in / commit
• After modification you must check in the documents.
• Files may be locked from check out to check in
• Otherwise there might be concurrency problems
Version control, using Git 9
Some version control systems
• Subversion from Apache
• Mercurial
• Git
• Git is a distributed version control system
• Pronounced ”get”.
• Started by Linus Torvalds (Linux), 2005
• Git can be used from NetBeans
• And other development environments

Version control, using Git 10


git
Git is a fast, open source, distributed version control system. Git was
initially designed and developed by Linus Torvalds for Linux kernel
development in 2005, and has since become the most widely adopted
version control system for software development.

Git is a simple command line tool for keeping a history on the state of
project source code and documents. You tell it to track files in your
project and periodically commit the state of the project when you want a
saved point. Then you can share that history with other developers for
collaboration, merge between their work and yours, and compare or
revert to previous versions of the project or individual files.
git vs. github
git != github

git is a version control system.


github.com is a web site where you can publish git repositories.

Typical workflow: use git locally to manage a set of files. Push or publish
to github to backup your work and share it with others.
git
git has changed the way developers think of branching and merging.

Branching and merging tends to be a big scary event with centralized


repositories.

Branching and merging are part of the daily workflow of developers


using git. git supports non-linear development.
Three main sections of a git project
Files tracked by git are in one of three states: committed, modified, or
staged.
This leads us to the three main sections of a Git project: the .git
directory, the working directory, and the staging area.
git file stages

Untracked Tracked
Working with a remote Git
repository
Multiple users can share a remote Git repository
1. Clone (copy) the project from the remote repository to a local repository
2. Work + commit to the local repository
3. Fetch the original project from the remote server, into another branch in
the local repository
4. Merge the 2 branches in the local repository
1. Merge happens on the local computer, not remotely
5. Push the project from the local repository to the remote repository
There are other (more advanced) ways to work using a remote Git
repository

Version control, using Git 16


Working with a remote Git
repository

Source http://thkoch2001.github.com/whygitisbetter/#everything-is-local

Version control, using Git 17


Working with a remote repository
Figure from http://git-scm.com/book/en/Distributed-Git-Contributing-to-a-Project

Version control, using Git 18


Hosting a remote repository
• A remote Git repository must be hosted on a Git repository server
• https://github.com/
• https://bitbucket.org/
• Alternatively you can setup your own Git repository server

Version control, using Git 19

You might also like