一、从git上克隆项目到本地
git clone url
二、连接远程仓库并提交代码到github
1.配置用户名和邮箱
git config --global user.name "your name"
git config --global user.email "your email address"
2.创建空的本地仓库
git init
3.链接远程仓库
git remote add origin https://github.com/smilechenjia/vuepress.git
4.取消已链接的仓库
git remote rm origin
5.将项目所有文件添加到缓存中
git add .
6.将缓存中的代码提交到本地仓库
git commit -m "注释"
7.上传代码到远程库
git push --set-upstream origin master
8.从仓库拉取代码到本地
git pull origin master
三、生成ssh key并添加到github
1.生成公钥和私钥
ssh-keygen -t rsa -C "github用户名"
2.查看公钥
cat ~/.ssh/id_rsa.pub
3.添加ssh key
登陆github,依此点击头像->settings->new SSH
把新生成的公钥复制粘贴到这里
四、分支处理
1.新建分支
git checkout -b branchname
git push origin branchname:branchname
2.删除分支
git push origin --delete branchname
3.切换分支
git checkout branchname
4.合并分支
git merge branchname
五、出现错误: refusing to merge unrelated histories
git pull origin master --allow-unrelated-histories
待补充...