title: JGit: How to get all commits of a branch? (Without changes to the working directory ...)
body: <p>how do I get all commits of a branch with JGit, without changing the working directory?</p>
  
  <p>Unfortunately the JGit docs are not very good ...</p>
  
  <p>In ruby with grit it is very easy:</p>
  
  <pre><code>repo = Grit::Repo.new(pathToRepo)
  
  repo.commits(branchName, false).each do |commit|
      doSomethingWithTheCommit
  end
  </code></pre>
  
  <p>Bye,
  hurik</p>