git use and common commands

git Introduction

  • git is a free open-source distributed version control system

  • git can be achieved shuttling back and forth between the various versions

  • git can be remotely managed code

  • git can do teamwork

workspace --add--> index --commit--> repository --push--> remote

 

git hosting platform

 

Use git step

  1. Install git, registered users

  2. The first step needs to be performed 2-4 use git, or start directly from step 5. Open git bash in any position, executiongit config --global user.name [用户名]

  3. Open git bash in any position, executiongit config --global user.email [绑定的邮箱]

  4. Configure key: open in any position git bash, execute ssh-keygen, all the way round, you can c/users/[用户名]/.sshyou can see the public and private keys in this directory, note that the private key must not move! ! ! Finally, the entire contents of id_rsa.pub file assigned to the line, find the ssh public key in personal settings, complete the paste

  5. Initialize the warehouse need to perform steps 5-7, if the warehouse when code updates directly to step 8 . Initialize the local warehouse: enter the local workspace (find a directory, this directory is the code), where the execution command git init, creates a .git folder, this folder is hidden by default, Note: This folder must not move! ! !

  6. Creating an online repository: Create an online repository of open source, created when the three options are not selected! ! !

  7. Associate local and online repository, run: git remote add origin [线上仓库SSH地址]

    If being given here, you can be performed before git remote rm originthe associated lines removed, washed and then re-add

  8. Add the workspace code to the staging area git add -A

    1. The staging area code is submitted to the local repository git commit -m '[这一次提交所做的事情]'

  9. The local repository push code line git push origin master. The first push when you need to enter yes

 

Common git commands

  • git init Initialize a local warehouse

  • git add Add native code to the staging area

  • git commit The code submitted to the local staging area warehouse

  • git push The local repository push remote code (online repository)

  • git remote add origin [线上地址SSH] Local warehouse associated with the line

  • git remote rm origin Out of line with related local warehouse

  • git status View the current status git repository

  • git log View commit log, you can see each commit record and the corresponding version number

  • git reset --hard [要回退的版本号] Back to a version

  • git clone [https线上地址] Cloning code to local

Guess you like

Origin www.cnblogs.com/Sunshinezty/p/11505576.html
Recommended