What is GIT?
-
Definition: is an open source distributed version control tool
-
Features:
- Code backup
- version control
- Collaborative opening
- Code traceability
-
Scenes:
- Team collaboration open project
-
principle:
-
Use: (15 commands)
-
Command Line
- Version rollback
- git reset --hard branch ID roll back to the specified version
- git reset --hard^ roll back to the previous version
- git reset --hard~2 roll back 2 versions
- revert instruction
- go merge
- git add
- git commit
- Branch switching: used to improve efficiency
- The relationship between different branches is parallel and will not affect each other
- Create: git branch branch name
- Modification: git merge branch name
- Switch: git checkout branch name
- Delete: git branch -d branch name
- View: git branch
- Code push command
- Alias definition of remote warehouse: git remote add remote name remote warehouse address
- Push code: git push -u remote name branch name
- Code pull
- Full pull: git clone
- Incremental pull: git pull
- Version rollback
-
tool
- TortoiseGit
- IDEA
- SmartGit [window recommended]
- SourceTree [mac recommended]
-
Two ways to connect to remote warehouses
-
User and password connection: each time you continue to communicate with the remote, you need to enter the user and password, http protocol address
-
SSH password-free login: configure the private key and public key on the servers of both parties, and then use the private key or public key for data encryption for communication between the two parties to ensure the security of data transmission, so there is no need to verify the user password every time, ssh protocol the address of
View git account
git config user.name
View git mailbox
git config user.email
Set local default remote warehouse information
# 设置用户 git config --global user.name "胥员员" # 设置邮箱 git config --global user.email "[email protected]"
Check whether the SSH public key has been generated
cd ~/.ssh
Generate SSH public key
ssh-keygen -t rsa -C "[email protected]" // 注意:此处需要敲3下回车
View public key
cat ~/.ssh/id_rsa.pub
Public key test
ssh -T git@gitee.com //输入yes
Push to remote warehouse
git remote add origin git@gitee.com:xu_member/xyy.git git push -u origin master