Git Basics-1

version control
what is version control
Version control (Revision control) is a software engineering technology used to manage our modification history of files, directories or projects during the development process, so as to facilitate viewing of the change history and backup to restore previous versions.

Realize cross-regional multi-person collaborative development
Track and record the history of one or more files
Organize and protect your source code and documentation
Statistical workload
Parallel development, improve development efficiency
Track and record the entire software development process
Reduces developer burden, saves time, and reduces human error
Simply put, it is a technology used to manage multi-person collaborative development projects.
Without version control or the version control itself lacks correct process management, many problems will be introduced in the software development process, such as software code redundancy, software process transactional, software development process concurrency, software source code. Security, and software integration issues.
Whether you are working or studying, or taking notes yourself, you have gone through such a stage! We desperately need a version control tool!

Multi-person development must use version control, otherwise the cost will be relatively high!

**Common version control tools
**

The mainstream version controllers are as follows:

Git
SVN (Subversion)
CVS (Concurrent Versions System)
VSS (Microsoft Visual SourceSafe)
TFS (Team Foundation Server)
Visual Studio Online
There are many version control products (Perforce, Rational ClearCase, RCS (GNU Revision Control System), BitKeeper, Monotone, Bazaar, Mercurial, SourceGear Vault), and now the most influential and widely used are Git and SVN.
Types of Version Control
1. Local version control

Record each update of the file, you can make a snapshot of each version, or record the patch file, suitable for personal use, such as RCS.

2. Centralized version control SVN

All version data are stored on the server, and developers can synchronize updates or upload their own modifications from the server. All version data is stored on the server. The user's local only has the previously synchronized version. If not connected to the Internet, Users can't see historical versions, can't switch version verification issues, or work on different branches. Also, with all data being kept on a single server, there is a high risk that this server will break, thus losing all data, and of course backing up regularly. Representative products: SVN, CVS, VSS

3. Distributed version control Git

Everyone has all the code! Security risks!

All version information warehouses are synchronized to each local user, so that all version history can be viewed locally, and can be submitted locally offline, just push to the corresponding server or other users when connected to the Internet. Since each user saves all version data, all data can be restored as long as there is no problem with one user's device, but this increases the occupation of local storage space.

There will be no failure to work due to server damage or network problems!
The main difference between Git and SVN
SVN is a centralized version control system, the version library is centralized on the central server, and when working, you use your own computer, so you must first get the latest version from the central server, and then work. After completing the work, you need to Push your finished work to a central server. The centralized version control system must be connected to the Internet to work, which requires high network bandwidth.

Git is a distributed version control system. There is no central server. Everyone's computer is a complete version library. When working, there is no need to connect to the Internet, because the versions are all on their own computers. The method of collaboration is as follows: for example, if you change file A on your computer, and others also change file A on your computer, you two only need to push your changes to each other, and you can see each other. to the other party's modification. Git can directly see what code and files have been updated!

Git is the most advanced distributed version control system in the world.
software download
Open [git official website] https://git-scm.com/ and download the version of git corresponding to the operating system.

If everything is slow to download, you can find a mirror!

The official website download is too slow, we can use the Taobao mirror to download: http://npm.taobao.org/mirrors/git-for-windows/

Download the corresponding version and install it!

Installation: The next step is no brainer! Installed and ready to use!
Start Git
After the installation is successful, there will be a Git item in the start menu, and there are 3 programs under the menu: you can also see the corresponding program by right-clicking on any folder!

Git Bash: Unix and Linux style command line, most used, most recommended

Git CMD: Windows-style command line

Git GUI: Git with graphical interface, not recommended for beginners, try to be familiar with common commands first
Common Linux Commands
1), cd: change directory.

2), cd . . go back to the previous directory, directly cd into the default directory

3), pwd: Display the current directory path.

4), ls(ll): All files in the current directory are listed, but the contents listed by ll (two lls) are more detailed.

5), touch: create a new file such as touch index.js will create a new index.js file in the current directory.

6), rm: delete a file, rm index.js will delete the index.js file.

7), mkdir: To create a new directory is to create a new folder.

8), rm -r: delete a folder, rm -r src delete the src directory
9), mv moves the file, mv index.html src index.html is the file we want to move, src is the target folder, of course, in this way, it must be ensured that the file and the target folder are in the same directory.

10), reset to reinitialize the terminal/clear the screen.

11), clear to clear the screen.

12), history View command history.

13), help help.

14), exit to exit.

15), # indicates a comment
Git configuration
All configuration files are actually saved locally!

View configuration git config -l

View profiles at different levels:

View system config git config --system --list #View current user (global) configuration git config --global --list
Git related configuration files:

1) gitconfig --system system level in the Git installation directory

2) Configuration only applicable to the currently logged in user --global global

Here you can directly edit the configuration file, and it will respond here after setting it through the command.
Set username and email address (user ID, necessary)
The first thing to do when you install Git is to set up your username and e-mail address. This is very important because every Git commit will use this information. It is permanently embedded in your commit:

This setting only needs to be done once, if you pass the --global option, as Git will always use this information for everything you do on the system. If you wish to use a different name or e-mail address in a specific project, you can run this command without the --global option in that project. In short --global is a global configuration, not a specific configuration of a project.

Related Articles

Explore More Special Offers

  1. Short Message Service(SMS) & Mail Service

    50,000 email package starts as low as USD 1.99, 120 short messages start at only USD 1.00

phone Contact Us