Can we create a remote branch in git using jgit without checking out. For example I want to create a branch named foo from branch named bar in my remote repository without checking out branch bar locally.
You need to have at least one branch 'bar
' in your local repo in order to push it under a different name 'foo
'.
But you don't have to checkout that local branch 'bar
' first.
See this JGit push test example:
RefSpec spec = new RefSpec("refs/heads/bar:refs/heads/foo");
git1.push().setRemote("test").setRefSpecs(spec).call();