Front-end learning Notes on Git stuff

Git is a free, open source distributed version control system designed to handle any project, small or large, with agility and efficiency. The use of Git is also a common topic in the interview. In the daily development, it also bothers us for a long time. Let’s go into it together

I will introduce you from the following points, and you are ready to enter the world of Git

  • The meaning of high-frequency words

  • Git git

  • Several common Git operations

The introduction of high-frequency words

Git operation extensive and profound, many details, for daily development of us, familiar with a few common operations can solve daily problems. It is necessary for beginners to understand the meaning of the basic git vocabulary and how Git works, and it is also helpful to solve the “bugs” in Git operation.

  • Remote: refers to a computer stored at a remote location, usually a GitHub server.
  • Clone: To clone a github project onto your own computer.
  • Origin: refers to a remote repository (your own repository), that is, a source file.
  • Upstream: fork the address of someone else’s project, while your project is upstream.
  • Master: indicates the primary branch.
  • Pull: To pull code from your remote repository on Github to your local computer.
  • Push: Refers to submitting code to a remote repository on Github.

Git files are local repositories. The.git directory, which by default is hidden, contains the versions and associated information of all files.

Git git

1. Source Files:

  • Git remote -v: displays remote repositories, including source files and upper-layer source files.
  • Git remote add origin + git remote add origin
  • Git remote add upstream git remote add upstream
  • Git remote remove origin/upstream + git remote remove origin/upstream +

2. Initialization:

  • Git clone + git clone + git clone + git clone + git clone
  • Git init: a git file that contains no link information and is re-associated with the remote repository.
  • Git pull upstream master means to get the original project updated.

3. Submit:

  • Git add + file name: add a modified file to the staging area.
  • Git add. : Adds all the modified files to the staging area.
  • Git commit -m
  • Git push -u origin master: commit a temporary file to Github.
  • Git log: view the history of the commit.
  • Dir: view the subdirectory of the file.

4. Branches:

  • Git status: Check all conditions;
  • Git branch: displays branch information.
  • Git branch + branch name: creates a branch.
  • Git checkout + branch name:

Git git commands:

There are several common Git processes

Prerequisite: You can perform related operations on Git only after accessing the corresponding file directory.

Related folder command line operations:

  • CD + file name: Go to the file directory
  • cd .. / : Returns to the upper-level directory
  • Dir: view all subfiles under the current file

Scenario 1: Create a new project and establish an association

  1. Start by creating a new repository on Github

Click the button in the red box on the right to copy the warehouse address:

  1. Right click Git Bash Here to open it in local VSCode workplace

  1. Git clone + git clone + git clone

A new wxapp_font_reading_class1 folder is created locally

Situation two: Fork someone else’s project onto the machine

  1. Create a new folder under Workplace;

  2. Right-click the folder and click Git Bash Here to open it;

  3. Input in sequence:

    (1) git remote add upstream + fork (2) Git remote add upstream + fork (3) Git remote add upstream + forkCopy the code
  4. The fork file is created under the new folder.

Case 3: How do I keep up with fork’s project

  1. The association is established with fork’s project

    Type "Git pull upstream master" to update the codeCopy the code
  2. No association is established with fork’s project

    Git remote add upstream + fork git remote vCopy the code

Case 4: Git someone else’s project, but not through a fork

As an example, add the wxapp-starter file:

  • Create a “WXapp-Starter” repository on Github
  • Git Clone + links to other projects
  • Git remote Remove Origin
  • Remove.git (delete the.git file in the wxapp-starter file)
  • Git init (initialize.git file)
  • Git remote add Origin + add your own link to.git
  • Git Pull Origin Master

Case 5: Generic Git commit procedures (actions to be performed after every code change)

  1. Git status (check current file modification status);
  2. Git add. Git add. Git add.
  3. Git commit -m “comment”
  4. Git push -u origin master

The es6 file is used as an example

All you have to do is listen to the blue Blue

Git tutorial by Liao Xuefeng