刚接触 git,只需在 github 上为我本地制作的项目创建新的存储库。在 git init 之后,git 添加并提交所有文件,添加远程,最后尝试推送“git Push origin main”我在 github 上的项目,给了我一个错误
error: failed to push some refs to 'https://github.com/sam97/test.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.
我用终端做了这些来学习使用它
您好,假设您执行了所有应该执行的命令,您可能已经创建了一个自述文件(或者可能是另一个文件或进行了更改), 当你第一次在 github 上创建你的存储库时,终端显示远程上发生了你本地没有的更改。
“当前分支的尖端位于其远程对应分支的后面”
Git 告诉您从 REMOTE (github) 导入新更改并将其与您的代码(本地)合并,然后将其推送到远程。 尝试将这些文件拉到您的本地计算机上
git pull --rebase origin main
,然后git push origin main
您的项目。如果您感到困惑,请再次询问。