Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] How To Checkout with a Specified Tag using CheckoutCommand

Hi Feichi,

No NullPointerExceptions here. I pushed some tests that show this:

  https://git.eclipse.org/r/31802

Are you calling a method on the returned Ref? Because null is
returned in case it was not a branch that was checked out.

Regards,
  Nibor

> Hi Chris,
> 
> Thanks for your reply.
> 
> Actually I tried git.checkout().setName(" my_tag ").call(), it did
> checkout the tag, but it also throws a
> java.lang.NullPointerException.
> When I do a "git checkout my_tag" in git bash, it will checkout the
> version, and also it will tell me that "You are in 'detached HEAD'
> state..." Is this the reason why it throws a NullPointerException ?
> 
> Thanks again.
> 
> Feichi
> 
> 
> On Fri, Aug 15, 2014 at 12:56 PM, Chris Aniszczyk <
> caniszczyk@xxxxxxxxx > wrote:
> 
> 
> 
> When in doubt, it always helps to look at the corresponding tests...
> org.eclipse.jgit.api.CheckoutCommandTest
> 
> Should be as simple as git.checkout().setName("your version
> tag").call()...
> 
> Let us know if you need anymore help.
> 
> 
> On Fri, Aug 15, 2014 at 1:10 PM, Feichi Feng < fengfeichi@xxxxxxxxx >
> wrote:
> 
> 
> 
> Hi,
> 
> I am using JGit in my project. Currently I have a repository with
> version tags. Now I want to checkout a version. For example, I wanna
> do
> 
> "git checkout <versino_tag_here>" in a git bash.
> 
> I can successfully checkout with this command in a git bash. But is
> there anyway that I can do this using the JGit CheckoutCommand in
> Java code? Or any other ways to get this done using other classes of
> JGit library?
> 
> Thank you.


Back to the top