开发者

How to set tracking on an existing repo to a remote repo with ngit (or jgit)?

开发者 https://www.devze.com 2023-03-24 06:05 出处:网络
I am working on a gui based helper utility that will: Init a local repo, Init (bare) a remote repo Add .gitignore based on a project type

I am working on a gui based helper utility that will:

  • Init a local repo, Init (bare) a remote repo
  • Add .gitignore based on a project type
  • Commit all the files locally
  • Add a remote repo to the local config
  • Push master to the remote repo
  • Create a develop branch and pus开发者_运维百科h it to master

All this is done without git installed by using ngit (.NET port of jgit).

But I can't figure out how to setup tracking to track master to origin/master and develop to origin/develop using just ngit.

I can do it easily with

git branch --set-upstream master origin/master

However, I was hoping to avoid the dependency of a local git install.


Here is a Java snippet that corresponds to the --set-upstream option to git branch:

Git git = Git.open(new File("/home/repos/myrepo"));
CreateBranchCommand create = git.branchCreate();
create.setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM);
create.setName("develop");
create.setStartPoint("origin/develop");
create.call();
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号