git学习

echo "# test" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/iamyadi/test.git
git push -u origin master

…or push an existing repository from the command line

 
git remote add origin https://github.com/iamyadi/test.git
git push -u origin master

1、错误解决:
今天按照上面步骤,然后关联本地库的时候pull失败,错误为:fatal: refusing to merge unrelated histories
解决方案为:git pull 或者 git pull origin master, 修改为以下代码:
git pull origin master --allow-unrelated-histories

2、如果不小心commit了,但是还没有push,则可以输入git reset HEAD~1
意思是: 将版本库回退1个版本,将本地版本库的头指针全部重置到指定版本,且会重置暂存区,即这次提交之后的所有变更都移动到未暂存阶段
posted @ 2018-04-03 21:52  迪迪的博客  阅读(146)  评论(0编辑  收藏  举报