1 | git 提交命令 |
可能出现的问题:
执行git add README.md时出现fatal: pathspec ‘README’ did not match any files
- 原因:该命令是将文件加至暂存区域,表示该文件找不到,即是在目录里面不存在,创建好文件再添加。
执行第4条命令行时报错“fatal: remote origin already exists.”
- 解决:先输入git remote rm origin后重新输入一次即可。
执行git push -u origin master时报错信息如
“ ! [rejected] master -> master (fetch first)
error: failed to push some refs to ‘git@github.com:levyc/SpringAccessDB.git’
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., ‘git pull …’) before pushing again.
hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.”- 原因:github远程仓库发生了变化,但是本地没有fetch(抓取)新变化下来就push到远程仓库。只要先执行git pull –rebase origin master获取最新改动即可解决。
-push成功后但是Github上没有本地项目的文件。
- 原因:没有将项目里面的文件添加进去就commit(提交)了。用git add . 将目录内所有文件添加进暂存区域再提交即可。