git常用命令

git ssh key常用命令
git config --global --unset user.name
git config --global --unset user.email
ssh-keygen -t rsa -C "yourmail@gmail.com"
exec ssh-agent bash
eval ssh-agent -s
ssh-add ./id_rsa_github
在git bash下,直接touch config即可创建一个config文件
每个账号单独配置一个Host,每个Host要取一个别名,每个Host主要配置HostName和IdentityFile两个属性即可
Host的名字可以取为自己喜欢的名字,不过这个会影响git相关命令
例如:
Host mygithub 这样定义的话,命令如下,即git@后面紧跟的名字改为mygithub
git clone git@mygithub:PopFisher/AndroidRotateAnim.git
就相当于你配置的HostName真正的域名,映射成了Host后面的配置的名字

作者:指間的Coding
链接:https://www.jianshu.com/p/a3b4f61d4747
來源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
# gitlab
Host gitool.glanway.com
HostName gitool.glanway.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitlab
User yangjie
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
User yangjie
git 操作命令
添加到git add
git commit
git push
git pull
查看服务器上的分支:git branch -a
查看本地分支:git branch
切换到liyanglin分支:git checkout -b liyanglin origin/liyanglin
切换到master分支:git checkout master
删除远程分支liyanglin:git push origin --delete liyanglin
删除本地分支liyanglin:git branch -d Chapater8
原文地址:https://www.cnblogs.com/blueberry006/p/9848499.html