Basic usage

  • Git clone < repository address >

  • Create branch: git branch

  • Create and enter the branch: git checkout -b

  • Check your status: git status

  • Add all files: Git Add.

  • Git commit -m ‘Here is the description of the current commit’

  • Git pull

  • Git push

  • Check branches: git branch –list

  • To view branches (including remote branches) : git branch -a

Code submission specification

Format: type(scope) : Subject

(1) Type (mandatory) : the category of commit. Only the following identifiers are allowed: 👇

â‘  Feat: Submit new features

â‘¡ Fix: Fix the bug

â‘¢ docs: Only the document is modified

â‘£ style: adjust the code format without changing the code logic (e.g. modify Spaces, formatting, missing semicolons, etc.)

⑤ Refactor: Code refactoring without fixing bugs or adding new features

â‘¥ Perf: Performance optimization, code changes that improve performance

⑦ Test: Add or modify code tests

⑧ Revert: Undo the previous commit

⑨ Build: Changed build tool such as NPM instead of Grunt

â‘© chore: Changes to the build process or auxiliary tools and dependent libraries (such as document generation, etc.), e.g. webpack upgrade, etc. Db: Data upgrade script version number (including adding tables, modifying table fields, etc., which needs to be handled independently by separate branches and then PR to the main branch)

(2) Scope (optional) : Specifies the scope of the commit impact, such as the data layer, control layer, view layer, and so on, depending on the project
(3) Subject (must) : a short description of the commit, no more than 50 characters (it is recommended to start with a verb, such as: set, modify, add, Delete, undo, etc.)

Branch management

Master: the main branch on which projects are not normally developed dev: the development branch on which projects are normally developed

Version branch: Built under dev branch

BUG branch: Built under the current version branch

  • Feature: Describes the current branch type
  • XXX: indicates the project name
  • V1.0.0: indicates the version number
  • Xxxx-xx-xx: indicates the branch establishment date

Problems encountered

After pulling the latest master code, what should I do if I want to roll back the previous version?

You can use Git Reset to roll back the project version to any version that has been committed. This applies to files that have been added/committed but not pushed

Step one:

Check the commit hash using git log

Step 2: Reset to the specified version

How do I view and switch accounts? How do I view the commit history?

1. View the current login account

git config user.name
Copy the code

2. View the current login email:

git config user.email
Copy the code

3. Change the user name and email address

git config --global user.name "Your_username"
git config --global user.email "Your_email"
Copy the code

4. View the submission history

git log
Copy the code

Pull the remote master branch?

1.git branch

2.git pull origin master

Resolve pull remote code to local branch conflict?

1. Look at the conflict first

Git pull origin master

Feat -wenke is a local branch. You need to pull the master branch after the remote update

Resolve conflicts on the VS Code editor

1. Click Search and enter <<<

2. In the conflict area, click adopt the incoming changes!!

3. If the change is not resubmitted, pull and update the master branch, which will cause the following problem

4. You need to submit it first, then pull it back

Remote git master branch conflicts with local git init

1. Initiate git init to generate the master branch locally

2.git pull origin master

3.git add .

4. The git commit – am ‘ ‘

5. Git push needs to establish contact with the remote repository first

6. Git push –set-upstream Origin master

7. Solution: due to the initialization of the project, it directly covers all the code of the remote warehouse, but do not pay attention to this way is not desirable, to prevent the coverage of the code should not be covered, attention! git push -u origin master -f

After making a code merge request, what are some considerations for checking where the file changes?

1. Create a merge request

2. Check the file changes, need to pay attention to a few points

  1. Remove unnecessary whitespace, except to distinguish code
  2. Description of interface functions (One function corresponds to only the current logic, and the logic of other functions is not mixed. For example, to write a function to empty the current state, I put it on the interface function (mixed), but it is better to put it on the page uninstall useEffect to remove the empty state)
  3. Style naming is best in a namespace (with a highest generation name, for example.first.first-item.first-item2)
  4. Externally referenced files are placed at the top of the current page, and internally referenced files are placed below the externally referenced files
  5. If the result returned by the interface is empty, you can add a message (successful) before adding, deleting, modifying, and checking the function. If the interface fails, you should contact the backend to provide error information
  6. Ts can define data types without commas, (interface)

Undo local changes?

Use Git Checkout to undo local changes, that is, to abandon local changes to files that have been changed but have not been committed, and restore them to their original state

Note: This method does not apply to files that have been added/committed

Method 1: Undo all changes to the files that have been modified but have not been submitted, but do not include the new files

Method 2: git checkout filename undo the modification to the specified file. Filename is the filename

After the current branch commits a merge, the branch is merged by someone else. After the bug is fixed, the branch commits again.

Look at the problem

Mentor guidance:

The solution

1. Switch to the main branch and synchronize the latest code

2. Create a new development branch

3. The development…

4.git status

2, 3, 4, 5.1

Complete effect (remove useless commit)

Remote: Invalid Credentials, FATAL: Authentication failed?

Switch to the specified branch

Pull the latest code and the following problem occurs

Cause :password The password is incorrect (hh). Enter the correct password