I am using JGit for creating a new git repository, and everything already present in the folder, I save as new branch.
I am using
Git.init().setDirectory(workingDir).call();
(by-default master branch is created after above statement, so i rename it to "backupBranch"). because master I clone from a remote master later.
Problem is when I push the backupbranch, its pushed but no remote tracking I am able to establish.
from terminal: if I use git branch -vv
result is
master 5f1994c [origin/master] commitmsg
backupbranch 7a4d671 taking backup of file already in MyTests Folder..
According to link Make an existing Git branch track a remote branch? I can use
git branch -u upstream/foo
from terminal to specify any time after pushing backupbranch.
How to achieve it using JGit.
Following is code I am using
to create the backupbranch
git.branchRename().setNewName(backUpName).call();
git.add().addFilepattern(".").call();
RevCommit commit = git.commit().setMessage("taking backup of file already in MyTests Folder..").call();
then push it first time.
Iterable<PushResult> pushResult = git.push().call();
Please suggest the way I can specify remote tracking for existing branch.