【问题标题】:Git merge is saying I am already up to dateGit合并说我已经是最新的了
【发布时间】:2014-11-11 17:35:47
【问题描述】:

我对 git 还很陌生,到目前为止,我只需要解决一些简单的冲突。我有一个项目和一个团队成员,我正在努力。在他处理旧副本时,我推送了一堆我的更改(394344b)。当他推送他的更改时,他不知何故覆盖了我所有的更改。查看 git 日志,他似乎调用了 git revert,我猜这就是他丢弃我的更改的方式。

所以基本上,现在我想将我的更改与他在 git revert 调用后所做的更改合并。这可能吗?

我用被丢弃的代码创建了一个分支

git checkout 394344b -b a1

但每当我尝试合并两个分支时,它看起来与主分支没有任何不同。我假设这是因为 a1 中的所有更改都比 master 中的后者提交更早。

编辑:这是日志

* 1230d87 2014-09-16 | white back ground fix (HEAD, origin/master, master) [Isaac Paulsen]
* 6a44fe3 2014-09-16 | various fixe [Isaac Paulsen]
* 60f12a8 2014-09-16 | Revert 4c74c8e..b85ae54 [Isaac Paulsen]
* b85ae54 2014-09-16 | Revert "Revert 394344b..0268ad9" [Isaac Paulsen]
*   394344b 2014-09-16 | Merge branch 'master' of https://github.com/crobertsbmw/HuntDay [Isaac Paulsen]
|\  
| *   4c74c8e 2014-09-16 | Merge branch 'master' of github.com:crobertsbmw/HuntDay [croberts]
| |\  
| * | e6dcb12 2014-09-16 | added permit application lookup (a1) [croberts]
* | | 3ed349c 2014-09-16 | Various changes [Isaac Paulsen]
| |/  
|/|   
* | d6a5a30 2014-09-16 | twitter icon added [Isaac Paulsen]
|/  
* 1df231b 2014-09-16 | added search by code funcitonality [croberts]
* 57119d2 2014-09-16 | Fixed the emails [croberts]
* 209679f 2014-09-09 | updated app version [Isaac Paulsen]
* 74561e9 2014-09-04 | cordova.js added [Isaac Paulsen]
* e4ff4c8 2014-09-04 | Last commit. The plugins still aren't working. we need to figure that out [croberts]
* 3ebcf60 2014-09-04 | Added cordova.js and fixed some things [croberts]
* e5157b4 2014-09-04 | Changed the alerts to navigator.alert things [croberts]
* e5998e5 2014-09-04 | Commented out the magic decoder [croberts]
* 7d2bf8f 2014-09-04 | added cordova.js [Isaac Paulsen]
* e3fd1cf 2014-09-04 | Added gitignore [croberts]
* e4b9bc9 2014-09-03 | Create README.md [crobertsbmw]
* 8f6c0c8 2014-09-03 | Still trying to fix stuff [croberts]
* 5a215c1 2014-09-03 | Trying to get the repo set up [croberts]
* 282f07f 2014-09-03 | Fixing stuff [croberts]
* d9d85b6 2014-09-03 | First commit [croberts] 

【问题讨论】:

  • 你能粘贴git log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short的输出吗?

标签: git merge git-merge git-revert


【解决方案1】:

有很多方法可以意外删除 git 中的更改 - 'revert' 不是其中之一。与该开发人员聊一聊他认为自己在做什么。

假设您不想强制更新分支,您的正常恢复路径将是“还原”还原。

(注意,你没有提到你的分支名称,根据需要调整)

git checkout -b fix_reverts 1230d87
git revert 60f12a8
git revert b85ae54

然后在此基础上重新调整您的其他工作并继续正常工作。

【讨论】:

  • 错误:无法恢复 60f12a8... 恢复 4c74c8e..b85ae54
  • 这可能意味着后续 2 次提交中的某些内容导致了合并冲突。使用git mergetool 修复合并冲突。 stackoverflow.com/questions/6084483/…
  • 我在我的头上。我最终删除了 fix_reverts 分支以重新开始。并在 master 分支上输入: git reset --hard master 但现在当我执行 git status 时,我有一堆这些:.../huntday.js.BACKUP.12263。 .../huntday.js.BASE.12263.js 等。我很确定我不想跟踪这些文件
  • git clean 删除它们。 git config --global mergetool.keepBackup false 以防止它们被生成。
猜你喜欢
  • 2012-04-25
  • 2013-11-20
  • 2021-12-01
  • 2014-04-14
  • 1970-01-01
  • 1970-01-01
  • 2013-02-28
  • 1970-01-01
  • 2013-03-22
相关资源
最近更新 更多