2011-01-07 12 views
10

新しいコミットを作成することで変更をロールバックするために、 "git revert"を行うことは可能ですか?(古いコミットをチェックアウトしたり、新しいコミットローリングを作成しないハードリセットを行うのではなく変更を元に戻す)git revert in Egit

これは、すでにそこにプッシュされた変更を元に戻す必要がある場合に備えて、中央リポジトリを持っている場合には重要な機能のようです。

ありがとうございます!

答えて

3

commit from 5 days agoと入力すると「Merge」と呼びます。復帰コマンド「」(Shawn Pearce)を実装すると、すぐに利用できるようになります。

diff are here

public class RevertCommandTest extends RepositoryTestCase { 
     @Test 
     public void testRevert() throws IOException, JGitInternalException, 
         GitAPIException { 
       Git git = new Git(db); 

       writeTrashFile("a", "first line\nsec. line\nthird line\n"); 
       git.add().addFilepattern("a").call(); 
       git.commit().setMessage("create a").call(); 

       writeTrashFile("b", "content\n"); 
       git.add().addFilepattern("b").call(); 
       git.commit().setMessage("create b").call(); 

       writeTrashFile("a", "first line\nsec. line\nthird line\nfourth line\n"); 
       git.add().addFilepattern("a").call(); 
       git.commit().setMessage("enlarged a").call(); 
       writeTrashFile("a", 
           "first line\nsecond line\nthird line\nfourth line\n"); 
       git.add().addFilepattern("a").call(); 
       RevCommit fixingA = git.commit().setMessage("fixed a").call(); 

       writeTrashFile("b", "first line\n"); 
       git.add().addFilepattern("b").call(); 
       git.commit().setMessage("fixed b").call(); 

       git.revert().include(fixingA).call(); 

       assertTrue(new File(db.getWorkTree(), "b").exists()); 
       checkFile(new File(db.getWorkTree(), "a"), 
           "first line\nsec. line\nthird line\nfourth line\n"); 
       Iterator<RevCommit> history = git.log().call().iterator(); 
       assertEquals("Revert \"fixed a\"", history.next().getShortMessage()); 
       assertEquals("fixed b", history.next().getFullMessage()); 
       assertEquals("fixed a", history.next().getFullMessage()); 
       assertEquals("enlarged a", history.next().getFullMessage()); 
       assertEquals("create b", history.next().getFullMessage()); 
       assertEquals("create a", history.next().getFullMessage()); 
       assertFalse(history.hasNext()); 
     } 
} 
+0

私はそれがまだ単純にできないと確信しています。ありがとう! – Christian

10
  • あなたが現在チェックアウトに戻したいコミット上で右クリックしEGitの最新毎晩(0.11.xx)
  • オープン履歴の表示
  • をインストールブランチ
  • 「返品コミット」

- マティアス

+0

私はそれをしましたが、リモートリポジトリにコミットしてプッシュすることができませんでした。特定の古いコミットがHEADになることを望みます... – Lennon

+0

@Lennonので、リセットが必要です – Joqus

1

私は、低い評判にコメントすることはできませんが、私は念の誰に@Matthias孫の答えに最後のピースを追加したい、私のように、これを行う方法を探し経由でこれを見つけました。あなたがスクロールする必要はありませんので、彼の手順は以下のページ:

  • はあなたに戻したいコミット上で右クリックしEGitの最新毎晩(0.11.xx)
  • オープン履歴の表示
  • をインストール現在チェックアウトブランチ
  • クリックは

これは、「[前のコメントをコミット]元に戻す」履歴ビューの上部にエントリを追加します「を元に戻すには、コミット」。この新しいエントリを右クリックすると、元に戻す操作をコミットするオプションが表示されます。 @Lennon氏によれば、パッケージエクスプローラからコミットしたりプッシュしたりすることはできないので、履歴ビューから実行する必要があります。

この方法の欠点は、コミットのすべての変更を元に戻すことです。私はチェンジセットにあった特定のファイルだけをロールバックすることができるようにしたいので、誰かがこれを行う方法を知っていれば追加してください。

0

元に戻すファイル - >置き換え - > HEADリビジョン

関連する問題