[Version Control Tool 1] Git installation, registration and use

一、Git、Github、Gitee

1.1 Overview

Git is an open source distributed version control system for agile and efficient handling of any project, small or large.

Github is a website that provides git services to users. In this way, we don't need to deploy the git system ourselves. We can directly register an account on the website and use the git service provided by the website.

Gitee, commonly known as code cloud, is a domestic Git-based code hosting and R&D collaboration platform.

Digital Management Platform
Vue3+Vite+VueRouter+Pinia+Axios+ElementPlus
Permission System-Mall
Personal blog address

1.2 Advantages of Code Cloud over Github

  • Due to reasons that everyone knows, accessing Github will be very slow, and sometimes access will even fail. Since Code Cloud is a domestic platform, it allows you to experience flying speed.
  • Compared with GitHub, in addition to providing a free Git warehouse, Code Cloud also integrates functions such as code quality inspection and project demonstration. For team collaboration development, Code Cloud also provides project management, code hosting, and document management services, which are free for small teams of less than 5 people.

2. Github or Gitee registration

2.1 Registration

If you still have a Github or Gitee account, please register first. The addresses are as follows:

Github: https://github.com/

Gitee: https://gitee.com/

Here, we use Gitee Code Cloud as an example to explain. Follow the steps specified on the website to register and log in.

2.2 Create a warehouse

After logging in, click the "+" sign in the upper right corner, click "New Warehouse", fill in the warehouse name, and click the "Create" button at the bottom after completing the filling.

Note: You only need to fill in the warehouse name here. Be sure not to select "Use Readme file to initialize the warehouse"

Insert image description here

After creating the warehouse, the following interface appears, proving that the warehouse was successfully created:

Insert image description here

Next, don't close the page yet and wait for the following steps to be completed...

3. Git download and installation

Download address: https://git-scm.com/downloads

Select the corresponding system platform, download it, and install it in a fool-proof way.

After the installation is complete, open Run --> Enter the CMD command and press Enter to open the command line window

Enter the following Git command

git --version

The version number appears, which means the git installation is successful.

Insert image description here

4. Create a local warehouse

  1. In the start directory, find the Git directory and select Git Bash below:

    Insert image description here

  2. Click to open the git command line window:

    Insert image description here

  3. In the Git Bash window, complete the creation of the warehouse through the following instructions:

    cd d:  //切换到指定盘符(这里演示D盘)
    mkdir mygit  //创建一个新的文件夹并命名(mygit)
    dir | ls | ll //查看当前路径中所有的文件和文件夹
    cd mygit  //进入指定目录(mygit)
    

    Insert image description here

  4. Warehouse initialization

    git init  //初始化仓库
    

    Insert image description here

    At this time, there is an additional hidden .git file in the mygit directory

    Insert image description here

  5. Use the following instructions to create a file and write its contents:

    touch test.txt  //创建一个新的文件test.txt
    cat test.txt  //查看文件test.txt中的内容
    echo 'This is a test file'>test.txt  //将 ">" 前面的内容写入到 ">" 后面的文件 test.txt 中
    

    Insert image description here

  6. Clear everything in Gitbash

    reset  //清屏
    

    Now let’s actually upload the local files to the local warehouse:

    The file test.txt created above, or the file copied from other disks, are all "not included in the cache". Once the file is deleted, it will never be found again. Not there

    Put the file into the cache through the git add command. "File included in cache", can be found through git

    git add test.txt  // 将本地文件纳入缓存  如果是所有的文件,请使用"git add ."
    

    Submit the file to the local repository through the git commit command. "Files included in the repository" can be found anywhere on the computer

    git commit -m '描述内容'  //将纳入缓存的文件纳入版本库
    

    Insert image description here

    git status  //查看文件文件夹在工作区,暂存区的状态
    git log  //查看历史提交记录
    

Guess you like

Origin blog.csdn.net/qq_39335404/article/details/133638465