关于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 <远程主机名> <本地分支名>:<远程分支名>