Git - 操作/注意事项汇总(持续更新)

关于Git,廖雪峰老师的博客写的比较系统:
https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000
本文里主要是一些琐碎的细节问题.

远程仓库查看与删除

查看当前远程仓库

git remote -v

删除指定远程仓库

git remote rm origin
注: 远程仓库名一般为origin,也可能为其他名称

SSH key pair 生成

ssh-keygen -t rsa -C "your.email@example.com" -b 4096

注:如果存在多个key pair ,需重新命名文件,否则会覆盖原文件.

本地使用非默认ssh-key(Working with non-default SSH key pair paths)

If you used a non-default file path for your GitLab SSH key pair,you must configure your SSH client to find your GitLab private SSH key for connections to your GitLab server (perhaps gitlab.com).
For your current terminal session you can do so using the following commands (replacing other_id_rsa with your private SSH key):
Git Bash on Windows / GNU/Linux / macOS:

eval $(ssh-agent -s)
ssh-add ~/.ssh/other_id_rsa

注:替换 other_id_rsa 为对应的SSH 私钥文件

To retain these settings you’ll need to save them to a configuration file.For OpenSSH clients this is configured in the ~/.ssh/config file for some operating systems.Below are two example host configurations using their own SSH key:
(如果想保存这一设置,需要修改配置文件)

# GitLab.com server
Host gitlab.com
RSAAuthentication yes
IdentityFile ~/.ssh/config/private-key-filename-01

# Private GitLab server
Host gitlab.company.com
RSAAuthentication yes
IdentityFile ~/.ssh/config/private-key-filename

使用Git下载指定分支

使用Git下载指定分支命令为:git clone -b 分支名 仓库地址

git push

git push <远程主机名> <本地分支名>:<远程分支名>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值