git常用命令总结
供不熟悉记不住命令的朋友查看,每次找费时间。
windows配置git:
git config --global user.name “yourname” #配置全局的name
git config --global user.email “your@email.com"
git config --list # 查看配置的信息
然后在配置ssh登录:
ssh-keygen -t rsa -C "your@email.com"
输入命令后,一直回车即可。然后会在用户目录下生成.ssh文件夹。
本人的目录是:C:\Users\Administrator\.ssh
。
linux下配置git,以centos7为例
sudo yum -y install git
然后就和上述windows客户端描述相同啦。
生成的密钥默认在 cd ~/.ssh
然后拷贝公钥到github网页上面即可。
然后系统会自动在.ssh文件夹下生成两个文件,id_rsa和id_rsa.pub,用记事本打开id_rsa.pub
将全部的内容复制
、打开https://github.com/,登陆你的账户,进入settings
在key中将刚刚复制的粘贴进去
点击add ssh key,就ok辣!
然后再输入一下命令验证:
ssh -T git@github.com
$ ssh -T git@github.com
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
注意:这里一定要输入yes。否则还会验证不通过的!!
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Hi wangxizzz! You've successfully authenticated, but GitHub does not provide shell access.
还有几个常见的命令:
git init
git add .
git commit -m " "
git remote add origin “仓库url” // 配置分枝信息
git pull
git push origin master.