Git 开发相关命令

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]

*******未完待续

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值