简体   繁体   English

恢复到github上的先前本地版本

[英]Revert to previous local version on github

I have done some changes on a branch but i did not commit. 我在分支上做了一些更改,但是我没有提交。

Then i did a merge and now my changes are lost, is there any way i can recover it? 然后我进行了合并,现在我的更改丢失了,有什么办法可以恢复它?

Newbie github user here 新手github用户在这里

Do you mean that you (1) didn't commit changes to your local branch ("git add", "git commit") or (2) didn't push commits from your local branch to remote ("git push")? 您是说(1)没有将更改提交到本地分支(“ git add”,“ git commit”)还是(2)没有将提交从本地分支推送到远程(“ git push”)?

In first case - probably there is nothing you can do (since git never tracked your changes). 在第一种情况下-可能您无能为力(因为git从未跟踪您的更改)。

In second - You can use interactive rebase (see docs on "git rebase -i") to rewrite history of your local branch (you'd probably want to get rid of "merging commit" on top of your local branch. In any case be careful with any history rewrite, all gotchas related to amending commits, for example, applies here). 第二步-您可以使用交互式rebase(请参阅“ git rebase -i”上的文档)来重写本地分支的历史记录(您可能希望摆脱本地分支顶部的“合并提交”。)请务必对任何历史记录进行重写,例如,与修订提交相关的所有陷阱都适用于此)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM