Git 开发相关命令
使用git开发过程中有一些不常用的命令每次都要去查找,比较麻烦,因此整理备用
准备工作:已有git账号
文章目录
下载Git
- linux
sudo apt-get install git
- mac
APP Store - windows
官网下载
(linux和mac也可以从官网下载)
本地信息设置
用户名和邮箱
初次使用需要配置用户名和邮箱
git config --global user.name "ysLi"
git config --global user.email ys-li19@tsinghua.edu.cn
⚠️用户名和邮箱需要修改成自己的
ssh公钥
拥有git账号并且将公钥放在git账号中才能克隆仓库
生成ssh公钥
ssh-keygen -o
公钥默认放在~/.ssh/id_rsa.pub
中,拷贝文件内容添加到到Git账号中
(点击右上角头像–>setting–>SSH and GPG keys)
远程仓库
clone
git clone [repo-adress]
添加其他远程仓库
以repo
代表远程仓库名称
git remote add [repo] [repo-address]`
删除远程仓库
git remote rm [repo]
列举远程仓库
git remote -v
branch
切换分支
以repo
代表分支名称
git checkout [branch]
切换到新建分支
git checkout -b [branch]
列举分支
简单列举分支
git branch
列举分支及head信息
git branch -v
列举本地&远程分支
git branch -a
上传下载
上传
git push [repo] [branch]
下载
git pull [repo] [branch]
变基
git fetch [repo]
git rebase [repo]/[branch]
*******未完待续