Version Control: 1.what Is "Version Control", and Why Should You Care
Version Control: 1.what Is "Version Control", and Why Should You Care
Many people’s version-control method of choice is to copy files into another directory
Advantages
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
Disadvantages
5. What is Git?
The major difference between Git and any other VCS (Subversion and friends included)
is the way
Git thinks about its data. Conceptually, most other systems store information as a list of
file-based
changes. These other systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the
information they store as a set of files and the changes made to each file over time (this
is
commonly described as delta-based version control).
Following figure 2 Git doesn’t think of or store its data this way.
Instead
Figure 2:Storing data as changes to a base version of each file.
Git 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.
6.Git 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.
Git stores everything in its database not by file name but by the hash value of its
contents.
When you do actions in Git, nearly all of them only add data to the Git database. It is
hard to get the
system to do anything that is not undoable or to make it erase data in any way.
7.Git states
• 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.
• Committed means that the data is safely stored in your local database.
The working tree 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. Its technical name in Git parlance is the “index”, but the
phrase “staging area” works just as well.
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.
Your Identity
The first thing you should do when you install Git is to set your user name and email
address. This
is important because every Git commit uses this information, and it’s immutably baked
into the
commits you start creating:
you need to do this only once if you pass the --global option, because then Git will always
use that information for anything you do on that system. If you want to override this
with a
different name or email address for specific projects, you can run the command without
the
--global option when you’re in that project.
Your Editor
you can configure the default text editor that will be used when Git
needs you to type in a message. If not configured, Git uses your system’s default editor
you can also check what Git thinks a specific key’s value is by typing git config <key>:
Getting Help
If you ever need help while using Git, there are three equivalent ways to get the comprehensive
manual page (manpage) help for any of the Git commands:
9.Git Basic
Initializing a Repository in an Existing Directory
$ cd /c/user/my_project
$ git init
This creates a new subdirectory named. git that contains all of your necessary repository files — a
Git repository skeleton.
If you want to start version-controlling existing files (as opposed to an empty directory),
you should
probably begin tracking those files and do an initial commit.
That command does the same thing as the previous one, but the target directory is called mylibgit.