Notes: Git version management system

Git is a version management system (VCS). It can save the status of the document as an update record at any point in time, or it can reply to the update record at any point in time

  • Version management

Version management is a way to record file changes so that you can check the content of a specific version of the file in the future

  • Steps for usage
  1. Download git first (https://npm.taobao.org/mirrors/git-for-windows/)
  2. The next step all the way, after the installation is complete, it will appear in the right-click menu of the mouse, the most commonly used Git bash here
  • command
查看版本

git --version
查看分支

git branch
创建分支

git branch 分支名称
切换分支

git branch 分支名称


如果在此分支上的内容没有处理好,那么此分支上的内容会被带到转换的分支上
切换分支之前要保证每个分支互不干扰
合并分支

git merge 来源分支
删除分支

git branch -d 分支名称

先切换到其他分支上
分支被合并后才允许删除

-D 强制删除

Temporarily switch branches

存储临时改动

git stash
恢复改动

git stash pop
  • Git basic workflow
  1. git repository: used to store submission records
  2. Temporary storage area: temporarily store modified files
  3. Working directory: project directory managed by git
  4. Every time the developer submits the project status to the git warehouse, he must first submit the modified files from the working directory to the temporary storage area, and then submit the files in the temporary storage area to the git warehouse.

git configuration

  1. Before using git, you need to tell the git information, which is needed when the item git warehouse is submitted
  2. To modify the configuration information, repeat the command
  3. Configuration only needs to be performed once
配置提交人姓名

git config --global user.name 提交人姓名
配置提交人邮箱

git config --global user.email 提交人邮箱
查看git配置信息

git config --list

Submit steps

初始化git仓库

git init
查看文件状态

git status
追踪文件

git add 文件列表
向仓库中提交代码

git commit -m 提交信息
查看提交记录

git log

Revoke

用暂存区中的文件覆盖工作目录中的文件

git checkout 文件
将文件从暂存区中删除

git rm --cached 文件
将git仓库中指定的更新记录恢复出来,并且覆盖暂存区和工作目录

git rest --hard commitID 
commit 后的数字就是commitID

git branch

  1. For ease of understanding, you can think of a branch as a copy of the code in the current working directory
  2. Using branches allows us to separate from the main line of development, so as not to affect the main line of development

Master branch

  • The first time an update record is submitted to the git repository is a branch automatically generated
  • To maintain the stability of the code in the main branch

Development branch (develop)

  • As an opened branch, created based on the master branch

Feature

  • As a branch to develop specific functions, create based on the development branch

Save changes temporarily

  • All changes on the branch can be temporarily extracted and stored, so that developers can get a clean working copy, and temporarily move to other work
  • Find out which branch you are on before executing

Temporarily switch branches

存储临时改动

git stash
恢复改动

git stash pop

Guess you like

Origin blog.csdn.net/m0_47883103/article/details/108269154