title: git配置
categories:
- 基础配置
git操作
git默认操作为vim编辑器,和linux系统一样操作,这个一般github上新建仓库有指引的,就怕久了忘
- 添加用户名和邮箱
git config --global user.name "yourname"
git config --global user.email "youremail"
- 添加ssh,命令执行后敲三次回车获得公钥,根据路径复制公钥添加到github上即可
# 1.获得ssh
ssh-keygen -t rsa -C "youremail"
# 2.拿到id_rsa.pub中的内容
cat /root/.ssh/id_rsa.pub
# 3.到github设置 -> SSH和GPG秘钥 -> 新建一个 -> 复制id_rsa.pub中的内容最下面那个大框子提交即可
- 初始化仓库(必须的)
git init
- 添加内容(*代表提交全部)
git add *
- 提交代码至本地仓库
git commit -m 'first'
- 本地仓库与远程仓库链接(github/gitee的存储库)
git remote add origin https://github.com/自己的github用户名/自己的github仓库.git
- 将本地仓库的代码提交到远程仓库
git push origin master
- 拉取代码(这个比较妙)
git pull origin master
- 克隆仓库(把所有的都拉取过来(不限于自己的),相当于下载源码)
git clone https://github.com/别人的github用户名/别人的github仓库.git