git finishing (a)

Git

Introduction to Git

git is the world's most advanced distributed version control system, 
a lot of people know, Linus created the open-source Linux in 1991. Since then, the development of Linux systems, has become the largest server system software. Although Linus created Linux, but Linux is to grow by enthusiastic volunteers around the world to participate, so many people write code for Linux around the world, and that Linux code is how to manage it? The fact is that, by 2002, volunteers from around the world to source code files sent by Linus diff way, then by Linus himself by manually merge code! You may be thinking, why not put Linus Linux code into version control system do? Not a CVS, SVN these free version control system? Because Linus firmly opposed to CVS and SVN, these centralized version control system is not only slow, but also must be networked to use. There are some commercial version control system, although the ratio of CVS, SVN easy to use, but it is paid for, does not match the spirit of Linux and open source. However, by the year 2002, Linux systems have been developed for a decade, a large code base of hard to let Linus continue to manage through manually, community brothers also expressed strong dissatisfaction in this way, so Linus chose a commercial version control system, BitKeeper, BitKeeper's owner BitMover company out of humanitarian spirit, the authorization to use the free Linux community version control system. Excellent situation of stability and unity in 2005 was broken, because the Linux community gathered cattle, inevitably tainted with some of the Liangshan heroes of rivers and lakes habits. Samba developed by Andrew trying to crack BitKeeper protocols (so dry in fact, not only him), it was found in the company BitMover (monitoring job well done!), So the company BitMover anger, to recover the right to use the free Linux community.











Linus can apologize to BitMover companies to ensure strict discipline after the brothers, ah, this is impossible. The reality is this: of Linus spent two weeks own use C to write a distributed version control system, which is Git! Within a month, the source Linux system has been managed by Git up! Cattle is how to define it? You can taste. Git quickly became the most popular distributed version control system, especially in 2008, the line on the site GitHub, Git provides free storage for the open source project, many migrated to GitHub open source project began, including jQuery, PHP, Ruby, etc.



Comparison of centralized and distributed

Centralized: time code version behalf (svn) all of the work has focused on the central server, managed by the central server version. And we must work requirements when networking, upload and download from a central server. 
Distributed: representatives (git) distributed version control system, there is no central server, each person's computer is a complete repository. Compared to a centralized, distributed more secure. Of course, the time to develop distributed in more than one member of the group of companies, also we need to have a computer to act as a central server, but his role is different from the centralized central server, it only acts between members of the group "exchange." git: There are local and "central repository" of information, like the code and history, once the server has a problem, then find a new native code sync up after all submit before history can also be seen. svn: Everyone submit code to the "central repository", once the server has a problem, even if the latest code to find a go, is only the current time node as a new project to use, until all submissions can not see history to, for dealing with issues left over from history is not friendly. Git repository contains code libraries as well as local history library in the local development environment can record history and the history of stock SVN is a central repository, each compared with the submitted code must be connected to a central warehouse can take place. The advantage is: 1, you can see it in an offline environment, version 2 development history, when people act as if the development of a central repository Git repository hung up, any developer of a warehouse can be served as a central repository (but generally this will not set)





Windows install Git

Downloaded directly from the official website, then fool installation (best not to have a Chinese path name) 
After installation is complete, open Git Bash
To enter the name and email address of the machine used in the git above, it is similar to the registered
$ git config --global user. name "you register the name"
$ git config --global user.email "your email address"

Create Repository

The so-called repository is the version of the warehouse, repository, is similar to the warehouse ,, maven repository of all files that can be managed git up, the file read and write operations, Git can track method # create a folder $ mkdir learn1 # file into the folder you just created $ learn1 cd # view the current path $ pwd / c / the Users / Administrator / learn1 # git init command through this directory becomes git repository can manage $ git init Initialized empty Git repository in C: /Users/Administrator/learngit/.git/ second method to find a location, click on the right mouse button Bash Here Git # create a folder $ mkdir learn2 # just point at this time to enter the position has been created learn2 a folder # git init command through this directory becomes git repository can manage $ git init Initialized empty Git Repository in C: /rep/.git/ then you can write some files in it, linux is instructions may also be used herein



























Add files to a local warehouse

# Passed just written the file to a local repository 
$ git the Add a.txt
# no error description Success
# to view the current status (can be omitted)
$ git Status
the On Branch Master No commits yet Changes committed to BE: ( use "git RM --cached <File> ..." to unstage)       new new File: a.txt # at this time only added to the stage and did not submit to the local repository # submitted to the local libraries also need to commit about $ git commit -m "first submission" [Master (root-the commit) 77c2b2c] the first time submitted 1 File changed, 1 Insertion (+) the Create the MODE 100644 learn2 / a.txt # note must be added back -m remarks information, if the company not add, may suffer bear # continue to add code to submit it, repeat steps













 

Guess you like

Origin www.cnblogs.com/liudongshuai/p/11564741.html