git - 修复 Github repo 编辑和本地 repo 的问题
问题描述
我遇到了一个问题,文件大小写的更改不会推送到我的远程仓库。
我尝试使用git mv
更改标题,但它不起作用。我在 GitHub 上更改了文件的名称,并将更改提交到了 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 文件,保存,然后在本地更改了一些文件,并且想要推送。由于在网络中对 README 进行了更改,而我还没有下载它,因此我们存在冲突/分歧。
您可能希望将本地更改移动到另一个分支,例如temp
,签出到 master、pull 和 rebasetemp
到 master,因此它们被合并了。一切都很干净。如果您想重置您在 master 中的最后一次提交以将它们“释放”到暂存区,reset --soft HEAD~1
可以。然后你可以看到你的最后一次提交现在处于未提交状态。然后你可以checkout -b temp
,commit -m
你的本地更改,并检查回 master,pull
然后重新定位temp
到master
.
推荐阅读
- node.js - 使用 custom-react-scripts 库构建会导致内存泄漏
- java - java赋值同步生产者消费者
- html - 为什么我的引导类不起作用?
- ruby-on-rails - 光滑 - 使肖像图像与其他图像高度相同
- javascript - javascript函数找不到元素
- windows - 是否可以在没有管理员权限的情况下安装 .appxbundle(UWP/XAML 应用程序)?
- javascript - 匹配伪元素内容属性的正则表达式示例
- react-native - 创建新的 react-native 项目时出现“意外的令牌导入”错误
- python - Json,抓取到网页 - python
- websocket - NoVNC:如何为 WebSocket URL 指定 cookie