GitBash | origin master - 被拒绝(首先获取)| GitHub 存储库中没有文件

Ada*_*dam 0 git github git-push git-fetch git-bash

我被这段代码困住了。在 git fetch 之后,我遇到了困难,不知道下一步应该做什么才能将所有提交的文件发送到 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
Run Code Online (Sandbox Code Playgroud)

GitBash 代码

Sam*_*ert 5

如果您想保留自述文件,您可以拉取并重新设置它

git pull --rebase origin master
Run Code Online (Sandbox Code Playgroud)

然后将你的代码推回去

git push origin master
Run Code Online (Sandbox Code Playgroud)

如果您不需要自述文件,只需强制推送即可

git push origin master -f
Run Code Online (Sandbox Code Playgroud)