1

Hello i have problem with path to repo in ProcessBuilder. I had same problem once, but that solution didn't work this time. And my error looks

fatal: Not a git repository (or any of the parent directories): .git

Any ideas why the path is not working? repository root is

public static final String REPOSITORY_ROOT = "C:\\Workspace-git\\";

enter image description here

Solution

ProcessBuilder ps= new ProcessBuilder(new String[]{"git","pull",RepositoryConstants.REPOSITORY_ROOT+"cl-testowy"});
        ps.directory(new File(RepositoryConstants.REPOSITORY_ROOT+"cl-testowy"));

Thank you

qusqui21
  • 170
  • 1
  • 12

1 Answers1

2

You probably receive this error because you are not in the right local git directory, see :

Receiving “fatal: Not a git repository” when attempting to remote add a Git repo

What you can do, is to tell your process to be run from a particular directory with the directory method, in your case :

ps.directory(new File(REPOSITORY_ROOT+"cl-testowy"));
Community
  • 1
  • 1
Arnaud
  • 17,229
  • 3
  • 31
  • 44