Using command Git tools

Set the user name

 git config --global user.name '用户名'

Set-Mailbox

  git config --global user.email '邮箱地址'

View configuration information

 git config --list

Create Repository

git init

Submission a.txt (workspace) to the repository -> add the staging area -> Repository

git add a.txt
git commit -m '注释信息'

Discard the workspace content

 git restore a.txt

Display commit log details

 git log  

Display commit log Lite

 git log --pretty=oneline  

Back to the past or future

 git reset --hard 474fe876476f90d6af9faa36717816572644a579(版本id)

Workspace uncommitted changes to the staging area do not want to modify the fallback

 git restore a.txt

Modification has been added to the staging area fallback

git restore --staged a.txt

Modification has been submitted to the repository

  • Rollback -> Back to the past

Delete Files

git rm a.txt
git commit -m '注释'

Accidentally deleted

  • return to the past

Remote repository configuration

The company generated key

ssh-keygen.exe -t rsa -C '邮箱地址'

View Public Key

 cat id_rsa.pub
  • Page setting Click ssh and gpg keys complete the corresponding operation

Local library association github remote repository

 git remote add origin https://github.com/用户名/远程仓库名

Local libraries synchronized to the remote library

 git push -u origin master

Remote database recovery to the local library

  git clone https://github.com/用户名/远程仓库名 (克隆)

Local Kula fetch remote libraries

 git pull origin master

Branch Management

Creating a branch

 git checkout -b dev

Switching branch

 git checkout master

View branch

 git branch

Deleted branches

 git branch -d dev

Branches merge

 git merge dev
Published 24 original articles · won praise 1 · views 510

Guess you like

Origin blog.csdn.net/Mr_YXX/article/details/104603762