Gitee creates a repository and deploys the public key
- Sign up and log in to Gitee
- Create repository
①Enter the creation page
②Fill in the relevant information and click Create
- Windows generates public key
①Open the terminal
②Enter the following command in the terminal
#xx换成注册gitee的邮箱 ssh-keygen -t ed25519 -C "[email protected]"
③Follow the prompts and press Enter three times to generate the public key and private key.
④Public key
- deploy public key
①Enter the management page.
②Add personal public key , only personal public key supports write operations such as modification and deletion . Paste the public key generated by the terminal into the box
③Complete the previous step, return to the terminal and enter the following command
ssh -T [email protected]
If there are the following prompts, the deployment of the personal public key is successful
④Enter the following command in the terminal to complete the global settings
as follows:
⑤Create a random folder on the machine, click the right button to enter the terminal
⑥Complete the operations in the gitee simple command line introductory tutorial in the terminal
The following information appears, indicating success
⑦ Refresh Gitee
git workflow and implementation
The general workflow is as follows:
- Clone the Git resource as the working directory.
- Add or modify files on the cloned resource.
- You can update the resource if someone else modifies it.
- Review revisions before committing.
- Submit changes.
- After the modification is completed, if you find an error, you can withdraw the submission and modify and submit again.
- Create repository
① git init initializes a warehouse locally:
#创建一个文件夹,命名为0322demo mkdir 0322demo #进入0322demo文件夹 cd 0322demo #初始化该文件夹为git仓库 git init
② git clone imports the project from the Git repository
#复制图中地址 git clone [email protected]:AGi_R/demo22.git
- git status to view the current warehouse status
#创建test.txt NEW-ITEM test.txt #查看仓库状态 git status
- git add file to the staging area
#把test.txt添加到暂存区 git add test.txt #查看仓库状态 git status
- git commit -m 'xxxx' add to the local repository
#test.txt文件存到本地仓库 git commit -m 'test.txt'
- git pull synchronizes the remote repository to the local : check whether the remote repository is higher than the local version
#同步远程仓库到本地 git pull
- git push push to remote repository
#推送到远程仓库 git push
Common commands
- git clone remote repository to pull to local
git clone <-b branch> ( optional ) <address>
#默认状态为master分支 git clone [email protected]:AGi_R/demo22.git #拉取dev分支代码 git clone -b dev [email protected]:AGi_R/demo22.git
- git remote remote warehouse operation
git remote <action>
#查看远程仓库地址 git remote -v #添加地址 git remote add origin 地址
- branch management
①View branch
git brancn <action>
#查看分支 git brancn 查看本地分支 git brancn -a 查看所有分支
②Create a branch
#创建分支 #创建并切分支 git checkout -b xxx分支名字 #等价于下面两个命令 git branch xxx git checkout xxx #和远程分支关联,第一次需执行 切换分支之后,第一次推送代码到远程仓库 git push --set-upstream origin xxx分支名
③Switch branch
#切换分支 git checkout xxx分支名字
④Switch branch
#合并分支到当前分支 git merge xxx分支名字
⑤Delete branch
#删除分支 git branch -d 删除已合并的分支,有为合并代码不允许删除 git branch -D 强制删除,直接删除 #删除远程分支 git push origin --delete dev_new #删除远程分支
- Tag management
①View the log
git log
②Check the label
#查看所有标签 git tag #查看某个标签详情 git show <tagname>
③Create a label
#创建一个标签,命名为v0.0.1 git tag v0.0.1 #基于某一个版本,创建一个v0.9的标签 #f52c633使用git log 查看 git tag v0.9 f52c633 #基于某一个版本,添加备注,创建一个v0.1的标签 git tag -a v0.1 -m "version 0.1 released" 1094adb #切标签 git checkout tagname
④Sync and delete
git tag -d v0.1 #删除本地分支 git push origin v1.0 #推送某个分支到远程 git push origin --tags #推送所有分支到远程
⑤Delete remote tag
#先删除本地标签 git tag -d v0.9 #后删除远程标签 git push origin :refs/tags/v0.9
- ignore file .gitignore
Function: The configuration is successful when the file is ignored when the project is initialized for the first time, and others synchronize the code normally.
#创建 git config --global core.excludesfile .gitignore
Restore submitted files
git rm --cached 文件 git rm --cached -r 文件夹 git rm --cached -r .