归纳自己在使用git的时候猜过的坑
1,在使用 git push origin master 后终端输出如下
To https://github.com/gcusms/workplace
! [rejected] master -> master (non-fast-forward)
error: 无法推送一些引用到 'https://github.com/gcusms/workplace'
提示:更新被拒绝,因为您当前分支的最新提交落后于其对应的远程分支。
提示:再次推送前,先与远程变更合并(如 'git pull ...')。详见
提示:'git push --help' 中的 'Note about fast-forwards' 小节。
原因:自己在创建仓库的时候有README.md文件但是并未保存到自己的本地路径当中。
解决方案:在自己需要上传到github仓库路径下打开终端:
拉去master文件到当前目录下,保持工作区中的文件和仓库的文件一致。
git pull --rebase origin master
然后git push -u origin master
即可
对象计数中: 16, 完成.
Delta compression using up to 8 threads.
压缩对象中: 100% (16/16), 完成.
写入对象中: 100% (16/16), 368.92 KiB | 6.59 MiB/s, 完成.
Total 16 (delta 0), reused 0 (delta 0)
To https://github.com/gcusms/workplace
d6084f6..93a6ea1 master -> master
2使用git误删了工作区的文件
之前使用了git的这个命令删除了文件:
git rm -r handfind
在删除的文件位置打开终端输入一下两句即可
git reset HEAD 文件名称
git checkout 文件名称
没有出错的话文件应该回来了