GitBash |原始主机 - 拒绝(首先获取)| GitHub 存储库中没有文件
GitBash | origin master - rejected (fetch first) | no file in GitHub repository
我被这段代码卡住了。在 git 获取之后我遇到了一堵墙,不知道下一步应该怎么做才能将我所有提交的文件发送到 GitHub 服务器 - 现在只有一个文件 README.md保存新存储库时自动创建。感谢您的帮助。
Freeware Sys@DESKTOP-VK97GA5 MINGW64 ~/Desktop/Coding Staff/MustBeDone (master)
$ git status
On branch master
nothing to commit, working tree clean
Freeware Sys@DESKTOP-VK97GA5 MINGW64 ~/Desktop/Coding Staff/MustBeDone (master)
$ git remote add origin https://github.com/adambugaj/Lets-code.git
Freeware Sys@DESKTOP-VK97GA5 MINGW64 ~/Desktop/Coding Staff/MustBeDone (master)
$ git push -u origin master
To https://github.com/adambugaj/Lets-code.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/adambugaj/Lets-code.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.
Freeware Sys@DESKTOP-VK97GA5 MINGW64 ~/Desktop/Coding Staff/MustBeDone (master)
$ git fetch origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/adambugaj/Lets-code
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
GitBash code
如果您想保留自述文件,您可以拉取它并对其进行变基
git pull --rebase origin master
然后把你的代码推回去
git push origin master
如果你不想要自述文件,就强行推送它
git push origin master -f
看起来您只有创建 github 存储库时附带的默认 README.md 文件。
我会说,因为这是您第一次提交并推送到存储库
继续用力推动
git push origin master -f
还有另一种更简单的方法来处理新存储库。
您可以先对任何本地存储库执行 git clone https://github.com/adambugaj/Lets-code.git
。然后将所有文件放在该目录中(或者开始在那里编码),然后 git push origin master
就可以正常工作了。
初始克隆后,您可以根据需要edit/remove README.md 文件。 (但是为您的回购提供一个 README.md 文件总是好的)
我被这段代码卡住了。在 git 获取之后我遇到了一堵墙,不知道下一步应该怎么做才能将我所有提交的文件发送到 GitHub 服务器 - 现在只有一个文件 README.md保存新存储库时自动创建。感谢您的帮助。
Freeware Sys@DESKTOP-VK97GA5 MINGW64 ~/Desktop/Coding Staff/MustBeDone (master)
$ git status
On branch master
nothing to commit, working tree clean
Freeware Sys@DESKTOP-VK97GA5 MINGW64 ~/Desktop/Coding Staff/MustBeDone (master)
$ git remote add origin https://github.com/adambugaj/Lets-code.git
Freeware Sys@DESKTOP-VK97GA5 MINGW64 ~/Desktop/Coding Staff/MustBeDone (master)
$ git push -u origin master
To https://github.com/adambugaj/Lets-code.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://github.com/adambugaj/Lets-code.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.
Freeware Sys@DESKTOP-VK97GA5 MINGW64 ~/Desktop/Coding Staff/MustBeDone (master)
$ git fetch origin master
warning: no common commits
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.
From https://github.com/adambugaj/Lets-code
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
GitBash code
如果您想保留自述文件,您可以拉取它并对其进行变基
git pull --rebase origin master
然后把你的代码推回去
git push origin master
如果你不想要自述文件,就强行推送它
git push origin master -f
看起来您只有创建 github 存储库时附带的默认 README.md 文件。 我会说,因为这是您第一次提交并推送到存储库 继续用力推动
git push origin master -f
还有另一种更简单的方法来处理新存储库。
您可以先对任何本地存储库执行 git clone https://github.com/adambugaj/Lets-code.git
。然后将所有文件放在该目录中(或者开始在那里编码),然后 git push origin master
就可以正常工作了。
初始克隆后,您可以根据需要edit/remove README.md 文件。 (但是为您的回购提供一个 README.md 文件总是好的)