-1

I'm writing the code based on this example, but would like to use correct upstream that has been set up for the branch.

const branch = await repo.getCurrentBranch();
const branchRefspec = branch.name();
const remoteRefspec = await Git.Branch.upstream(branch);
const remote = await repo.getRemote('origin');
await remote.push(
    [`${branchRefspec}:${remoteRefspec}`],
    {
        callbacks: {
            credentials: verifyUser,
        },
    },
);

For some reason, this code does nothing. I couldn't find any documentation on what exactly does this parameter has to be, and what goes after the semicolon. Whatever it is, it doesn't look like good old git's refspecs.

If the refspec is left the way it is in example (i.e. from and into the same branch) somehow it works.

Why this code doesn't work? What refspec should I pass there and why?

polkovnikov.ph
  • 6,256
  • 6
  • 44
  • 79

1 Answers1

0

I checked with the libgit2 folks and your refspecs must be of the expanded form refs/heads/master:refs/heads/master when pushing. You cannot simply use master:master.

rcjsuen
  • 873
  • 1
  • 6
  • 12
  • Why not `refs/heads/master:refs/remotes/origin/master`? It doesn't make any sense to push to the local `master` on a remote. – polkovnikov.ph Apr 30 '18 at 15:26
  • I'm not sure I follow. The `refs/heads/master` on a remote is "your version" of `refs/remotes/origin/master`. Check the [Pushing Refspecs](https://git-scm.com/book/en/v2/Git-Internals-The-Refspec) section of the link you linked to. – rcjsuen Apr 30 '18 at 21:55