git/list[1] front-page[2] threads[3] people[4] search[5] about
 

How to do equivalent of "git-reset --hard" and "git revert HEAD" using jgit?

From
Farrukh Najmi <farrukh@wellfleetsoftware.com>
Date
Nov 13, 2008, 17:43 UTC
Message-ID
<491C6734.2060607@wellfleetsoftware.com>
I need some guidance on how use jgit to implement the following methods:
     /**
      * Rolls back all uncommitted changes so Index and worspace are 
rolled to committed state in HEAD version.
      * Functionally equivalent to "git reset --hard HEAD"
      *
      */
     public void rollback() {
     }
     /**
      * Undoes the last commit.
      * Functionally equivalent to "git revert HEAD"
      *
      * @param versionNameToRevertTo Version of Commit to revert to
      */
     public void revert(String versionNameToRevertTo) {
     }

It seems that I will have to walk the Tree and check status of each file to decide what to do with it. The TreeWalk api is not obvious from the javadoc.

TIA for any guidance you can provide.
-- 
Regards,
Farrukh Najmi

Web: http://www.wellfleetsoftware.com
Message 1 of 1 in “How to do equivalent of "git-reset --hard" and "git revert HEAD" using jgit?”
  1. Farrukh NajmiNov 13, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.