Class CheckoutCommand

java.lang.Object
org.eclipse.jgit.api.GitCommand<Ref>
org.eclipse.jgit.api.CheckoutCommand
All Implemented Interfaces:
Callable<Ref>

public class CheckoutCommand extends GitCommand<Ref>
Checkout a branch to the working tree.

Examples (git is a Git instance):

Check out an existing branch:

 git.checkout().setName("feature").call();
 

Check out paths from the index:

 git.checkout().addPath("file1.txt").addPath("file2.txt").call();
 

Check out a path from a commit:

 git.checkout().setStartPoint("HEADˆ").addPath("file1.txt").call();
 

Create a new branch and check it out:

 git.checkout().setCreateBranch(true).setName("newbranch").call();
 

Create a new tracking branch for a remote branch and check it out:

 git.checkout().setCreateBranch(true).setName("stable")
                .setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM)
                .setStartPoint("origin/stable").call();
 
See Also: