git init 把一个目录变成git管理仓库
git remote add origin github项目地址 把一个已有的本地仓库与github关联,
git add . 增加所有新增或改动的文件
git add -u --update 更新有改变的文件,即提交所有有变化的文件
git add -A --all 提交已被修改和已被删除的文件,不包含新的文件
git commit -m “提交时添加的备注”
git pull origin master --allow-unrelated-histories 拉取远程内容
git push -u origin master 传入github
遇到问题,上传失败fatal: refusing to merge unrelated histories
git checkout master // 切换到要提交代码的分支
git pull origin master --allow-unrelated-histories //加上后面这个选项允许不相关历史提交
git push origin master //提交到远程分支
注:首先需要pull,发现refusing to merge unrelated histories,因为两个仓库提交历史不一致,无法pull拉取远程信息,所以需要在GIT命令中添加一句代码:–allow-unrelated-histories允许不相关历史进行提交,最新的版本需要添加–allow-unrelated-histories
echo “# bst” >> README.md
git init
git add README.md
git commit -m “first commit”
git remote add origin https://github.com/liuYongleo/bst.git
git push -u origin master