git tutorials Study Notes (1)

git tutorials to learn from Liao Xuefeng's official website

1. Recognizes git

git and svn contrast

Centralized version control system (svn) biggest problem is must be networked to work, if good, bandwidth is large enough in LAN, fast enough, if available on the Internet, encountered Suman, it may submit a 10M file you need five minutes, that's not the people to suffocate ah.

That distributed version control system (git) and a centralized version control system (svn) different? First, the distributed version control system there is no "central server" on everyone's computer is a complete repository, so when you work, you do not need networking, because the repository is on your own computer . Since there is a complete repository on everyone's computer, and that more than one person how collaborative it? Let's say you change a file on your computer A, your colleagues also changed the file on his computer A, then, between the two of you just need to modify their respective pushed to the other side, we can see each other's edited.

2. Install git

Use Git on Windows, you can directly from the Git official website to download the installer , installation tutorial to see here ,

Installed, the operating window open directly git, similar cmd window, and to set their own mail user name, for identifying

$ git config --global user.name "Your Name"
$ git config --global user.email "[email protected]"

3. Create Repository

What is the repository of it? Warehouse repository, also known as the English name Repository , you can simply understood as a directory, all files in this directory can be inside Git to manage, modify each file, delete, Git can be tracked so that any moment can be traced history, or you can "restore" at some point in the future.

So, create a repository is very simple, first of all the first step, selecting a suitable place, create an empty directory:

$ Mkdir learngit 
$ learngit cd 
$ pwd
 / Users / michael / learngit

pwdCommand is used to display the current directory.

Step two: By git initcommand this directory can become a Git repository management

$ git init
Initialized empty Git repository in /Users/michael/learngit/.git/

Git instantly put the warehouse built, and to tell you is an empty warehouse (empty Git repository), careful readers can find more than a directory under the current .gitdirectory, the directory is to track and manage Git repository, nothing one thousand million will not manually modify the file or folder, or change the mess, put the Git repository to destroy.

If you do not see the .gitdirectory, it is because this directory is hidden by default, use ls -ahthe command you can see.

4. The basic steps git

Add a folder in the repository file, for example, readme.txt, says:

Git is a version control system.
Git is free software.

Remember to add the new file must be in the repository folder, otherwise git will not be found.

The first step: command git addtells Git, to add files to the repository:

$ git add readme.txt

The second step, use the command git committells Git, the submission of documents to the repository:

$ git commit -m "wrote a readme file"
[master (root-commit) eaadf4e] wrote a readme file
 1 file changed, 2 insertions(+)
 create mode 100644 readme.txt

-mEnter behind this explanation is submitted, you can enter any of the content, of course, the best is meaningful, so you can from the history list easy to find change records.

git commitAfter the successful implementation of the command will tell you 1 file changed: a file is changed (we readme.txt file newly added); : 2 insertionsinsert the two lines (readme.txt have two lines).

Why add files Git needs add, commita total of two steps it? Because commitit can submit many files at once, so you can multiple adddifferent files, such as:

$ git add file1.txt
$ git add file2.txt file3.txt
$ git commit -m "add 3 files."

 

Guess you like

Origin www.cnblogs.com/LeoXnote/p/11459266.html