About Git-Dangbangtian's distributed version management software

 

In this article, refer to the blog written by the big guy to learn Git .

The blog address is:

https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000

 

1) Git is the most distributed version control software in history.

2) What is the difference between distributed Git and centralized SVN ?

  1. SVN , centralized, has a central server as the absolute core. However, Git , everyone's computer can be used as a server. For example, colleague A and colleague B have modified the same file on the computer. Then, the file on the computer of A or B is not used as the standard, but Yes, you can push A 's changes to B , B 's changes to A , and then merge the files.
  2. SVN , submitting code must be connected to the central server (for example, the central server and your computer are in the same local area network, or your computer can access the central server on the Internet); and Git , everyone's computer can be There is a library that allows files from both sides to be merged when there is a network. When there is no network, you can also submit the modified files to git on the local machine first , and then merge them when there is a network. However, when git is used, there must also be a computer that acts as a temporary "central server" for merging versions.

3) How to use?

  1. First look at how to download: https://git-scm.com/downloads   This is the git official website, download the installation file for the corresponding system from this (mine is windows ) .
  2. After the installation is complete, find Git Bash in the start menu and enter

 

 

This is for self-reporting. As a member of a distributed version management cluster, of course you need something to prove your identity.

  1. create a repository,

a) mkdir is to create a directory (big guy, when creating a directory, do not contain Chinese characters, otherwise you will be responsible for the consequences). pwd is to view the current directory path.

 

 

b)  Repository initialization

 

 

 

After the repository is initialized, there will be a .git hidden file in the newly created directory, which can be seen by entering the window explorer (if you have set "hidden files visible" under the folder options ) ;

If you are in this directory and execute the ls command, you will not see anything. But execute ls -ah , you can see the hidden file .git .

c ) There is a detail to know, all version control software can only perform version control on text files (or files that can be opened as text files), and the text encoding is preferably UTF-8 . Those audio, video files, and word files can only be compared to the binary codes they converted to know that the file has changed.

d ) Use git to add a file ; for example, we create a readme.txt file in the newly created directory above , then I can use the following command

 

 

to bring this file into version control.

After executing this command nothing happens, that's right, according to the Unix philosophy, no message is the best message. 80% of the news is that there is a problem, hahaha.

Then, execute git commit to commit the file to the repository .

 

 

 

OK. In this way, a file is submitted. ( Note that the submitted files must be in the library you created. For example, if you create a git library in the C:/user/a directory , the files you want to submit must be in directory a . If it is in a directory In addition, when you add , this kind of thing will appear.

Files outside the repository are not allowed to commit... well, well , you're the boss, you say it )

 

 

4) Common commands:

git log to view all version records (git log --pretty=oneline puts each commit on one line for easy viewing )

git reset --hard [ version number ] can restore the files on the local repository to the files on the specified repository;

 

 

 Follow-up and Git will be concentrated here.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324976433&siteId=291194637