Git Basics
Git Basics
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
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
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.
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
Source http://thkoch2001.github.com/whygitisbetter/#everything-is-local