gitlab4j-api icon indicating copy to clipboard operation
gitlab4j-api copied to clipboard

projectAPI add readme?

Open fengshaokun opened this issue 3 years ago • 1 comments

How to create a readme and create a default 'master' branch when creating a project

fengshaokun avatar Jun 02 '22 02:06 fengshaokun

@fengshaokun I have created an example of how to create a new project with the default readme. Does it answer your question?

public class ReadmeExample {
    public static void main(String[] args) throws GitLabApiException {
        final String url = "http://localhost:8090";
        final String personalAccessToken = "glpat-";

        GitLabApi gitLabApi = new GitLabApi(url, personalAccessToken);

        Project project = new Project().withNamespaceId(1L).withName("Project Name").withDefaultBranch("main").withInitializeWithReadme(true);

        gitLabApi.getProjectApi().createProject(project);
    }
}

bensofficial avatar Aug 22 '23 10:08 bensofficial