The most complete arrangement of git installation, configuration environment and related knowledge points

foreword

git is a version control tool for multi-person development

1. Version control classification

  • 1. Local version control: suitable for personal use, version update (RCS)
  • 2. Centralized version control: All version data is stored on the server, and collaborative developers synchronize or update or upload their own modifications (svg, cvs) from the server.
  • 3. Distributed version control: All version information is synchronized to local users, which can be submitted offline and locally, and then pushed to the corresponding server when there is a network. Each user saves all version data , as long as there is one If there is no problem with the user's device, it can be restored. Because everyone owns all the code, there are security risks , and there will be no problem of inability to work due to server damage or network problems.

2. Installation and configuration

Git official website: https://git-scm.com/
1. Download the corresponding version
insert image description here
2. Install directly (downloaded before, go to the corresponding environment variable to clear the environment variable and then uninstall and reinstall)
3. The installation is successful There will be a git GUI on the right click
insert image description here
: the git of the graphic sister, not recommended for beginners, it is better to use the command
git Bash: the style used is the most similar to Linux, and the most used
git GMD: the command line similar to the Windows style
4. Configuration

  • git config --global user.name “Your Name”
  • git config --global user.email “[email protected]

3. Common commands

  • git init creates a new git code base
  • git add specifies the file to the temporary storage area
  • git commit -m "" submit files to the warehouse area
  • git rm deletes files in the workspace
  • git checkout branch switch branch
  • git checkout -b branch Create a new branch
  • git status shows changed files

Supplement the most complete instructions (process)
0. Warehouse
git init //Create a git code library in the current directory
git init directory name//Create a new directory to create a git code library
1. Download and install
2. Configuration
3. Configuration information in git bash
Configure
git config --global user.name "name"
git config --global user.email "mailbox"
git config --global core.editor "compiler name"
git config -e (for current warehouse configuration)
git config -e --global (for all warehouse configurations)
View
git config --list //View global and system configuration
git config --system --list //View system configuration
git config --global --list //View global configuration User name + email address
Pull the project down
git clone (project address)
to view and check the project branch (branch management)
Git branch //View the current branch
Git branch -a //View the local warehouse branch
Git branch -r //View the remote Warehouse branch
git checkout -t branch name // switch branch
git checkout // create a branch

After changing the corresponding code
//cache your own local code
git pull //remote to local
//resolve conflicts, negotiate, whose plan to use
Git merge branch name//merge branch
git add file name//add the specified file to the temporary storage If you don’t add it, you will add the modified one to the temporary storage area.
git add directory //add the directory to the temporary storage area, including subdirectories
git commit -m "" //submit to the local warehouse
git push to push
other
git branch -d branches name//delete branch
git push origin --delete branch name//delete remote branch
git branch -dr

Fourth, the difference between git and svn

svn

  • Centralized, with a central server
  • You can't use svn when you're offline, and you can't use svn to submit code when there is a problem with the server. Every time you work, you need to get the latest version from the server, and then work. After the work is completed, push your own part to the server. High requirements on the network.
  • Changes in the svn branch will affect other people, and the svn branch is the complete directory of the entire repository
    git
  • Distributed, no central server
  • The submission of the git branch is for a certain submission. The overhead of git branch creation is smaller. The collaborative method is that one person changes A on the computer, and the other person also changes A. You only need to push each modification to the other party. You can see the modification of the other party, and you can directly see which codes and files have been updated

Five, git push and git fetch

  • git push downloads the changes in the remote warehouse and merges them with the local branch
  • git fetch downloads the changes from the remote warehouse without merging them with the local branch

Six. git merge and git rebase

Same point:

  • Both are used for branch merging
    . The difference:
  • git merge will create a new commit object, and the branches together will point to this new commit object, and this method will keep the previous commit object.
    git rebase will find a common commit ancestor of the two branches, then extract all commit records after the current branch, add the commit to the target branch, and the merged commit record is a linear record

7. How to restore the error location of the online code to the original error location in the development environment?

Just adjust a package and use
the npm source-map library to locate errors. The SourceMapConsumer constructor passes in the .js.map file, and passes in the line number and column number for the instance to get the mapped source line number and column number

8. Tag management

Git tag -a version number (it can be executed without the -a option, but it will not record when the tag was played, who played it, and will not let you add a tag annotation. I recommend always creating annotations tag.)
Git tag view

Core
working directory + temporary storage area + resource warehouse area + remote git warehouse
Up: git add. git commit git push
Down: git pull git reset git checkout

Work area: working directory
Temporary storage area: temporary storage of changes, which is a file, saving information that will be submitted to the file list
Warehouse area: safe storage of data, where all versions of data are stored

Nine. Ignore files (mainly configured in gitignore)

*txt will be automatically generated,
ignoring all files ending in text
! lib.txt but this file is excluded
/dist only ignores the dist file in the root directory, excluding ist files in other directories
build/ ignores all files under build

10. Document Status

1. Not tracked
2. Has been stored without modification
3. Modified but not stored
4. Temporary storage stage

Guess you like

Origin blog.csdn.net/qq_59079803/article/details/124107699