首页 \ 问答 \ git(sourcetree)回到没有被推送的提交,并被意外“颠倒”(git (sourcetree) go back to commit that has not been pushed and was 'reversed' accidentally)

git(sourcetree)回到没有被推送的提交,并被意外“颠倒”(git (sourcetree) go back to commit that has not been pushed and was 'reversed' accidentally)

我对git修改还是很陌生,可能只是失去了很多工作(但我希望有一种方法可以回来,这就是我在这里问的原因)。

我在OsX上使用SourceTree进行git修改。 我没有犯下相当长的一段时间,现在只是想进行大量的修改。 我选择在提交后立即推送。 当推送花了很长时间,我检查了我的文件夹,发现我意外地选择了一个不应该签入的大文件夹。所以我取消了推送(我收到了一个类似commit的消息,但推送不成功)。

所以,即使我中断了推送,我仍然在我的主分支中看到了这个提交。 我想撤销这个,所以我可以再次提交(这次没有构建文件夹)。 我右键点击提交,然后点击“反向提交...”选项。 但不是删除这个修订版本,而是添加了另一个名为'Revert'的修订版本,我想撤销这个修订版本''。

糟糕的是 - 现在我所有的本地变化似乎都消失了,而且我的文件从一个月前就处于状态。

因为提交(我取消了推送)仍在列表中,我想知道我能否以某种方式回到那里? 是否有机会获得上个月我做出的本地更改? 我确实备份了我的文件,但这也差不多有两周了。

这就是sourcetree目前的样子:

SourceTree屏幕截图

如你所见,先前成功的提交/推送是在5月20日。然后今天我尝试提交/推送新功能,但在推送过程中被中断。 然后我'反转'这个(中断)提交,它将我所有的本地文件从5月20日重置为状态。Sourcetree显示有2个推动(我假设是中断推动和推动'反向'承诺)。

有什么办法可以在今天投入使用之前回到当地的州吗?

非常感谢


I'm still quite new to git revisioning and maybe just lost plenty of work (but I hope there is a way to go back, that's why I'm asking here).

I use SourceTree on OsX for git revisioning. I didn't commit for quite a long while and now just wanted to commit plenty of changes. I selected to push immediately after the commit. When the push took very long, I checked my folder and noticed that I accidentally had selected a big build folder that should not be checked in. So I cancelled the push (I got a message something like commit was successful but push was not).

So, even though I interrupted the push, I still saw this commit in my master branch. I wanted to undo this, so I could commit again (this time without the build folder). I rightclicked on the commit and there was a 'Reverse commit...' option, which I clicked. But instead of removing this revision, it added another revision labeled 'Revert "Name of the commit i wanted to undo"'.

Bad thing is - now all my local changes seem to have gone and my files are on the state from one month ago.

since the commit (of which I cancelled the push) is still in the list, I wonder if I can somehow go back there? Is there any chance to get the local changes I made during last month back? I do have a backup of my files, but that's also almost two weeks old.

This is how sourcetree currently looks like:

SourceTree Screenshot

as you can see, the previous successful commit/push i made was on may 20. Then today I tried to commit/push new features, but interrupted during pushing. Then i 'reversed' this (interrupted) commit, which aparently reset all my local files to the state from may 20. Sourcetree shows that there are 2 Pushs to make (which I assume are the interrupted push and the push for the 'reverse' commit).

Is there any way I can go back to my local state I had right before committing today?

Thank you so much


原文:https://stackoverflow.com/questions/17071895
更新时间:2024-02-11 16:02

最满意答案

很抱歉地说,但我认为你最好的选择确实是Ant插件。

每次我必须在我的pom.xml中使用Ant时,我都不寒而栗,但在某些情况下,这是最简单的选择。 学会拥抱它,它会为你节省一些头痛:-)

你也可以编写你自己的Maven插件,但这可能会更多的工作。

另外一个选择是创建一个shell脚本来附加值,然后使用maven-exec-plugin调用它。 不过,在这种情况下,你将不得不处理不同的操作系统。


Sorry to say, but I think your best option really is the Ant plugin.

I shudder every time I have to use Ant in my pom.xml, but in some cases, it's the easiest option. Learn to embrace it, it will save you some headaches :-)

You could probably also write your own Maven plugin, but that would likely be more work.

One other option would be to create a shell script to append the value, and then call that using the maven-exec-plugin. You'll have to deal with different operating systems in that case, though.

相关问答

更多
  • 我相信你需要安装M2E Eclipse插件而不是Maven。 安装Maven只会为您提供命令行工具。 它与Eclipse集成无关 I believe you need to install M2E Eclipse plugin instead only Maven. Installing Maven only give you the command line tools. It has nothing to do with Eclipse integration
  • 请参阅http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html src/main/java Application/Library sources src/main/resources Application/Library resources src/main/filters Resource filter files src/main/assembly ...
  • 很抱歉地说,但我认为你最好的选择确实是Ant插件。 每次我必须在我的pom.xml中使用Ant时,我都不寒而栗,但在某些情况下,这是最简单的选择。 学会拥抱它,它会为你节省一些头痛:-) 你也可以编写你自己的Maven插件,但这可能会更多的工作。 另外一个选择是创建一个shell脚本来附加值,然后使用maven-exec-plugin调用它。 不过,在这种情况下,你将不得不处理不同的操作系统。 Sorry to say, but I think your best option really is the ...
  • 你可以使用nashorn-maven-plugin io.github.michaldo nashorn-maven-plugin 0.0.1
  • 在Maven土地上,这些被称为模块。 有一种很好的方法可以将项目进一步划分为非常独特的部分。 人们以不同方式处理Maven。 我见过有实际项目模块的项目,然后是10个左右的实现模块。 大多数人将它们用于上述分离。 最有可能的是,您需要所有模块才能正常工作。 要修改项目,您需要Maven。 我不知道Eclipse是否有嵌入式maven,但至少NetBeans有。 有了它,你可以修改你想要的任何东西,然后用Maven构建它,这应该只是一个简单的点击。 In Maven land, these are calle ...
  • MAVEN_OPTS是来自操作系统的环境变量。 您可以在启动maven之前无论如何设置它。 在bash(linux)中: export MAVEN_OPTS=... 在Windows上: set MAVEN_OPTS=... 我想你甚至可以编辑'mvn.bat'shell脚本的'mvn'来获得不同的变量。 MAVEN_OPTS is a environment variable from the OS. You can set it anyway you want before launching ma ...
  • 如果运行mvn:dependency它会显示它将从该文件夹引用的jar文件列表。 我养成了在每个jar之前删除此文件夹的习惯,它们不再显示在mvn中:依赖项已运行且不会尝试下载它们。 如果他们添加了maven命令来忽略这些文件夹,那就太好了。 目前,没有删除此文件夹就无法让maven忽略它们。 这适用于任何人在网络上设置maven repo而不连接到互联网 - 例如工作场所构建不能依赖不安全或不断变化的互联网回购 if run mvn:dependency it brings up the list of ...
  • 没有直接。 您可以通过antrun maven插件使用Ant的复制任务 。 请参阅映射文件名 maven-antrun-plugin 1.6

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)