Git详细用法
- Git版本: git version 2.42.0.windows.2
- 有的主分支名是 master、有的是main
安装
连接远程仓库
配置用户名及邮箱
git config --global user.name "your name"
git config --global user.email "your_email@youremail.com"
git config user.name
git config user.email
生成密钥
ssh-keygen -t -rsa -C "your_email@youremail.com"
clip < ~/.ssh/id_rsa.pub
仓库关联
git remote add origin git@gitee.com:xxxx/xxx.git
git remote rm orign
git remote -v
基础用法
查询
git status
git branch
git log
git log --oneline
git log --oneline --graph
git log --pretty=oneline
工作流
git init
git add .
git commit -am"提交记录"
git push origin master
git pull
分支管理
git branch develop
git switch
git merge develop
git restroe
git branch
git branch -v
git branch --merged
git branch --no-merged
git branch --no-merged master
git checkout master
git merge --no-ff develop
远程仓库交互
git remote -v
git ls-remote <remote>
git remote show <remote>
进阶用法
标签
git tag
git tag -l
git tag --list
git tag -l "v1.0.0*"
git tag -a v1.3 -m "version 1.3"
git show v1.3
git tag v1.3
git tag -a v1.2 commit-id
git push origin v1.3
git push origin --tags
git tag -d v1.3
git push origin :refs/tags/v1.3
git push orgin --delete v1.3
压缩提交记录
git add .
git commit -amend
代码合并
git merge dev
创建快照
git archive -o xxx.zip master
git archive -o xxx.zip commit_id
git archive -o xxx.zip commit_id dir
git archive -l
git archive --list
克隆项目
git clone https://github.com/xxx/xxx.git
git clone https://github.com/xxx/xxx.wiki.git