pcottle/learnGitBranching · error · GitError
Tags are not allowed as sources for pushing
Error message
Tags are not allowed as sources for pushing
What it means
git push does not accept a tag as the source ref; this engine models that by rejecting any options.source that resolves to a ref of type 'tag'. Real git likewise requires pushing tags via explicit refspecs like refs/tags/x.
Source
Thrown at src/js/git/index.js:1139
}
return inOrder;
};
GitEngine.prototype.push = function(options) {
options = options || {};
if (options.source === "") {
// delete case
this.pushDeleteRemoteBranch(
this.refs[ORIGIN_PREFIX + options.destination],
this.origin.refs[options.destination]
);
return;
}
var sourceBranch = this.resolveID(options.source);
if (sourceBranch && sourceBranch.attributes.type === 'tag') {
throw new GitError({
msg: intl.todo('Tags are not allowed as sources for pushing'),
});
}
if (!this.origin.doesRefExist(options.destination)) {
console.warn('ref', options.destination);
this.makeBranchOnOriginAndTrack(
options.destination,
this.getCommitFromRef(sourceBranch)
);
// play an animation now since we might not have to fast forward
// anything... this is weird because we are punting an animation
// and not resolving the promise but whatever
this.animationFactory.playRefreshAnimation(this.origin.gitVisuals);
this.animationFactory.playRefreshAnimation(this.gitVisuals);
}
var branchOnRemote = this.origin.resolveID(options.destination);
var sourceLocation = this.resolveID(options.source || 'HEAD');View on GitHub (pinned to 5b09d0ff96)
Solutions
- Use the tag push syntax/refspec (git push origin v1 is rejected; use the dedicated tag push path or refs/tags/v1)
- Delete/recreate the ref as a branch if you meant a branch
- Check resolveID(options.source).attributes.type before pushing
Example fix
// before git push origin v1 // after git push origin refs/tags/v1
Defensive patterns
Strategy: type-guard
Validate before calling
var src = engine.resolveID(options.source);
if (src && src.attributes.type === 'tag') throw new Error('use refs/tags/ refspec'); Type guard
function isTagRef(engine, id) {
var r = engine.resolveID(id);
return !!r && r.attributes && r.attributes.type === 'tag';
} Prevention
- Never use bare tag names as push sources
- Push tags via explicit tag refspecs
When it happens
Trigger: Calling the push API (or typing git push) where options.source resolves through resolveID to a ref with attributes.type === 'tag', e.g. git push origin v1.
Common situations: Trying to push a tag with branch syntax; level scripts that mistakenly use a tag name as a source.
Related errors
- ' + branchName + ' is not a branch!
- ' + branchName + ' is not a remote tracking branch! I don't
- --delete doesn't make sense without any refs
- --delete only accepts plain target ref names
- cannot delete branch ' + options.destination + ' which doesn
AI-assisted analysis of pcottle/learnGitBranching@5b09d0ff96 (2026-08-27).
Data as JSON: /api/errors/601346b4909b3eee.
Report an issue: GitHub.