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
-
Install git, registered users
-
The first step needs to be performed 2-4 use git, or start directly from step 5. Open git bash in any position, execution
git config --global user.name [用户名]
-
Open git bash in any position, execution
git config --global user.email [绑定的邮箱]
-
Configure key: open in any position git bash, execute
ssh-keygen
, all the way round, you canc/users/[用户名]/.ssh
you 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 -
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! ! ! -
Creating an online repository: Create an online repository of open source, created when the three options are not selected! ! !
-
Associate local and online repository, run:
git remote add origin [线上仓库SSH地址]
If being given here, you can be performed before
git remote rm origin
the associated lines removed, washed and then re-add -
Add the workspace code to the staging area
git add -A
-
The staging area code is submitted to the local repository
git commit -m '[这一次提交所做的事情]'
-
-
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线上地址]