2、出现 base) admin1@Ning:/media/admin1/hdd1/Code/GitCode/Man_Fish$ git push -u Man_Fish main
error: src refspec main does not match any
error: failed to push some refs to ‘https://github.com/Tongzi-Zhang/Man_Fish.git’
如果你还没有对本地仓库进行任何提交,那么 main 分支(或其他分支)不会存在。Git 会报错由于没有可推送的内容。 解决方法:
创建一个提交,然后再进行推送:
bash
复制代码
git add .
git commit -m “Initial commit”
git push -u Man_Fish main
3、 (base) admin1@Ning:/media/admin1/hdd1/Code/GitCode/Man_Fish$ git push -u Man_Fish main
To github.com:Tongzi-Zhang/Man_Fish.git
! [rejected] main -> main (fetch first)
error: failed to push some refs to ‘git@github.com:Tongzi-Zhang/Man_Fish.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. 这个错误信息表明,远程仓库的 main 分支包含本地仓库没有的内容,因此你的推送被拒绝了。这通常是由于:
远程仓库的 main 分支有新的提交,而你本地的 main 分支还没有同步这些更改。
解决方案