修复Github repo编辑和本地repo的问题



我遇到了一个问题,对文件大小写的更改不会推送到我的远程repo。

我尝试使用git mv来更改标题,但它不起作用。我在GitHub上更改了文件的名称,并将更改提交到repo。现在我的本地repo不会将更改推送到远程。

我不愿意将旧的提交拉到本地的repo中,因为我已经做了很多不想丢失的更改,并且无法远程提交。还有别的办法吗?

cd would-you-rather
git add .
git commit -m '9th commit'
On branch main
Your branch and 'origin/main' have diverged,
and have 3 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working tree clean
git push  
To https://github.com/xxxx/xxx.git
! [rejected]        main -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/xxx/xxx.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我想你在Github网站上更改了一些东西,你还没有下载它。例如,当我在Github web UI中更改了README文件,保存,然后在本地更改了一些文件,并想要推送时,我通常会看到这种情况。由于修改是在web到README中完成的,而我还没有下载它,我们有冲突/分歧。

您可能希望将本地更改移动到另一个分支,例如temp,签出到master,拉出并将temp重基到master,因此它们被合并。一切都很干净。如果你想将上一次提交在master中重置为release;把他们送到集结区,reset --soft HEAD~1就行了。然后您可以看到您的最后一次提交现在处于未提交状态。然后,您可以checkout -b temp,commit -m您的本地更改,并签出回主,pull,并将temp重置到master上。

最新更新