1. Install the git client on the PC
After the installation is complete, you can right-click in the corresponding folder and select 'Git bash here' to start the git command line interface
Enter "git -- verison" on the command line to view the version
2. User name and email configuration
Each PC equipped with git client needs to be configured with the corresponding user name and email address, so that git knows who is making the submission when submitting the version, and check the configuration items through the 'git config --list' configuration item
git config --list
Configure the user name and user mailbox globally on the current PC through the intent command
git config --global user.name "用户名"
git config --global user.email "用户邮箱"
3. Warehouse generation and file submission
git init
Set the current folder as a git warehouse through 'git init'. After executing this command, a hidden folder of '.git' will be added to the current folder
git status
'git status' to view the status of the current warehouse
git add "文件路径(比如,./文件名)"
Add the code file to the cache area through the add command
git commit -m '提交修改的说明内容'
Submit the modified content in the cache area through the commit command, you need to add the version log, that is, the content after -m
git log
View the version through the git log command
git reset --hard '版本号'
Select the version you want to return to through the git reset command
4. Ignore list
Create a file named '.gitignore' in the directory of the current folder. In this file, you can add files that need to ignore the tracked modification, such as '*.txt', to ignore the modification of all txt files.
5. Create a branch
git branch
git branch View the current branch list
git branch '分支名称'
git branch 'branch name' creates a new branch
git checkout '分支名称'
git checkout 'branch name' switches the working environment to the corresponding branch
git merge '分支名称'
Use the git checkout command to switch to the branch that you want to actively execute the merge, and merge the corresponding branch through git merge 'branch name'
git branch -d '分支名称'
To delete the corresponding branch through the above command, it needs to be executed under other branches
6. Remote warehouse upload and download
Generate a public key file via ssh -keygen
ssh-keygen -t rsa -C '邮箱名'
Copy the public key to 'ssh and gpg keys' in github's personal settings
Push the code to the remote repository
#通过remote命令连接远程仓库,origin为远程仓库的别名,可自定义
git remote add origin '远程仓库的ssh地址'
#提交代码至远程仓库
git push -u origin master
Download the remote warehouse to the local
git clone 'url地址'
git pull origin master