Skip to content
Advertisement

Jgit – checkout from a specific branch

I am using jgit. I want to create and checkout a new branch. I have seen the git.checkout.createnewbranch command. Is there a way to specify the base branch for the checkout, say “test” (or) we have to checkout,pull “test” first and then checkout/create the new branch from it?

Advertisement

Answer

Yes, it’s possible:

JavaScript

Don’t forget to call git.close() or use try-with-resources once you are done with git.

Advertisement