Location>code7788 >text

Git Tutorial 1

Popularity:673 ℃/2024-08-14 19:41:13

I. What is Git

1, Git is a free, open source, distributed version control system. Use the warehouse (Repository) database records file changes, each file in the warehouse has a complete version of the change records.

2, the version control system can track changes in each file, making collaboration between project members more efficient.

3. Version control systems:

(1) Centralized: SVN, all files are on the central Server, and only one copy is saved per computer.
① Modify the file: The computer downloads the latest version of the file from the Server, modifies it and uploads it to the Server.
② Advantage: Easy to operate.
③ Disadvantage: If Server has a single point of failure, the whole system crashes.
(2) Distributed: Git
① Advantage: Each computer has a complete repository, which can be modified locally without thinking about network problems. Supports offline work, even if the Server fails, it will not delay the normal work of the computer.


Second, Git installation

1. Test the command for a completed installation: git -v.


Third, the way to use Git

1. The way Git is used:

(1) Command line.
(2) Graphical interface (GUI).
(3) IDE plug-ins/extensions. Such as VsCode, IDEA integration.

2, command line: distinguish Linux commands, Git commands in the beginning are git. followed by specific commands.


Git initialization settings

1, git config operation, set the user name, e-mail, etc.. You can know who submitted the file.

(1) global: valid for all warehouses, without it, valid only for the current warehouse.
(2) Configure the user name:git config --global "Roy"
(3) Configure the mailbox:git config --global "xxx@"
(4) Storage Configuration: Save user name, password, etc. without having to enter them each time.git config --global store
(5) View Information:git config --list


V. New warehouses

1, Repository (Repo) to track the addition, deletion, deletion and other records of each file so that it can be restored to a previous version.

2. Create a warehouse:

(1) Create locally on your computer:git init
(2) Clone an existent repository from a remote location:git clone

3、git init:

(1) Indicates that the current repository is managed by git.

(2) You can't just delete the .git folder, otherwise it will destroy the git directory, which is now just a normal directory.
(3) Orders:git init <project-name>If you want to create a new local repository, omit project-name and the current directory will be the repository.

4、git clone:

(1) Clone an already existing repository from a remote Github, Gitee.
(2) Orders:git clone <url>, clone a remote repository.

5. Create a folder:mkdir xxx,make directory。

6. Switch the catalog:cd,change directory。