Difference between specifying refspec with git push --tags or not












1















I stumbled upon this rather obscure problem pushing tags to a remote using the two commands git push --tags and git push --tags origin master. They are not behaving the same in the following situation:



Initial situation



I am trying to push a newly created tag (git tag test) to a remote repo that is one commit ahead because somebody else pushed a commit to it and I did not pull the latest changes. As graphic:



Remote [master] (one commit ahead):
A ----- B ----- C ---- D
Local [master] (one commit behind):
A ----- B ----- C
(tag:test)


Problem



git push --tags is working as expected:



Total 0 (delta 0), reused 0 (delta 0)
To https://remote.gitrepo.com/path/to/project
* [new tag] test14 -> test14


git push --tags origin master gets rejected and errors:



Total 0 (delta 0), reused 0 (delta 0)
To https://remote.gitrepo.com/path/to/project
* [new tag] test15 -> test15
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://remote.gitrepo.com/path/to/project'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


Question



Why is git push --tags origin master trying to push something apart from the tag?
I am asking why the command is trying to push the branch to the remote and not why it is being rejected










share|improve this question




















  • 1





    See the docs, that's what they say it does: "...in addition to refspecs explicitly listed on the command line."

    – jonrsharpe
    Nov 21 '18 at 16:13













  • Possible duplicate of Cannot push to GitHub - keeps saying need merge

    – phd
    Nov 21 '18 at 16:46






  • 1





    stackoverflow.com/…

    – phd
    Nov 21 '18 at 16:46











  • The problem has nothing with tags, it's a problem with non-fast-forward push of master. Run git push origin master and you will get the same error.

    – phd
    Nov 21 '18 at 16:46













  • @jonrsharpe Ahh, that does make a whole lot of sense. Thanks. My first command does push all tags and the second one pushes all tags and the ref specified... I've read through the push docs so often and never really read the whole sentence.

    – Daniel Habenicht
    Nov 21 '18 at 17:00


















1















I stumbled upon this rather obscure problem pushing tags to a remote using the two commands git push --tags and git push --tags origin master. They are not behaving the same in the following situation:



Initial situation



I am trying to push a newly created tag (git tag test) to a remote repo that is one commit ahead because somebody else pushed a commit to it and I did not pull the latest changes. As graphic:



Remote [master] (one commit ahead):
A ----- B ----- C ---- D
Local [master] (one commit behind):
A ----- B ----- C
(tag:test)


Problem



git push --tags is working as expected:



Total 0 (delta 0), reused 0 (delta 0)
To https://remote.gitrepo.com/path/to/project
* [new tag] test14 -> test14


git push --tags origin master gets rejected and errors:



Total 0 (delta 0), reused 0 (delta 0)
To https://remote.gitrepo.com/path/to/project
* [new tag] test15 -> test15
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://remote.gitrepo.com/path/to/project'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


Question



Why is git push --tags origin master trying to push something apart from the tag?
I am asking why the command is trying to push the branch to the remote and not why it is being rejected










share|improve this question




















  • 1





    See the docs, that's what they say it does: "...in addition to refspecs explicitly listed on the command line."

    – jonrsharpe
    Nov 21 '18 at 16:13













  • Possible duplicate of Cannot push to GitHub - keeps saying need merge

    – phd
    Nov 21 '18 at 16:46






  • 1





    stackoverflow.com/…

    – phd
    Nov 21 '18 at 16:46











  • The problem has nothing with tags, it's a problem with non-fast-forward push of master. Run git push origin master and you will get the same error.

    – phd
    Nov 21 '18 at 16:46













  • @jonrsharpe Ahh, that does make a whole lot of sense. Thanks. My first command does push all tags and the second one pushes all tags and the ref specified... I've read through the push docs so often and never really read the whole sentence.

    – Daniel Habenicht
    Nov 21 '18 at 17:00
















1












1








1


1






I stumbled upon this rather obscure problem pushing tags to a remote using the two commands git push --tags and git push --tags origin master. They are not behaving the same in the following situation:



Initial situation



I am trying to push a newly created tag (git tag test) to a remote repo that is one commit ahead because somebody else pushed a commit to it and I did not pull the latest changes. As graphic:



Remote [master] (one commit ahead):
A ----- B ----- C ---- D
Local [master] (one commit behind):
A ----- B ----- C
(tag:test)


Problem



git push --tags is working as expected:



Total 0 (delta 0), reused 0 (delta 0)
To https://remote.gitrepo.com/path/to/project
* [new tag] test14 -> test14


git push --tags origin master gets rejected and errors:



Total 0 (delta 0), reused 0 (delta 0)
To https://remote.gitrepo.com/path/to/project
* [new tag] test15 -> test15
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://remote.gitrepo.com/path/to/project'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


Question



Why is git push --tags origin master trying to push something apart from the tag?
I am asking why the command is trying to push the branch to the remote and not why it is being rejected










share|improve this question
















I stumbled upon this rather obscure problem pushing tags to a remote using the two commands git push --tags and git push --tags origin master. They are not behaving the same in the following situation:



Initial situation



I am trying to push a newly created tag (git tag test) to a remote repo that is one commit ahead because somebody else pushed a commit to it and I did not pull the latest changes. As graphic:



Remote [master] (one commit ahead):
A ----- B ----- C ---- D
Local [master] (one commit behind):
A ----- B ----- C
(tag:test)


Problem



git push --tags is working as expected:



Total 0 (delta 0), reused 0 (delta 0)
To https://remote.gitrepo.com/path/to/project
* [new tag] test14 -> test14


git push --tags origin master gets rejected and errors:



Total 0 (delta 0), reused 0 (delta 0)
To https://remote.gitrepo.com/path/to/project
* [new tag] test15 -> test15
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://remote.gitrepo.com/path/to/project'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


Question



Why is git push --tags origin master trying to push something apart from the tag?
I am asking why the command is trying to push the branch to the remote and not why it is being rejected







git git-push






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 8:58







Daniel Habenicht

















asked Nov 21 '18 at 16:12









Daniel HabenichtDaniel Habenicht

34919




34919








  • 1





    See the docs, that's what they say it does: "...in addition to refspecs explicitly listed on the command line."

    – jonrsharpe
    Nov 21 '18 at 16:13













  • Possible duplicate of Cannot push to GitHub - keeps saying need merge

    – phd
    Nov 21 '18 at 16:46






  • 1





    stackoverflow.com/…

    – phd
    Nov 21 '18 at 16:46











  • The problem has nothing with tags, it's a problem with non-fast-forward push of master. Run git push origin master and you will get the same error.

    – phd
    Nov 21 '18 at 16:46













  • @jonrsharpe Ahh, that does make a whole lot of sense. Thanks. My first command does push all tags and the second one pushes all tags and the ref specified... I've read through the push docs so often and never really read the whole sentence.

    – Daniel Habenicht
    Nov 21 '18 at 17:00
















  • 1





    See the docs, that's what they say it does: "...in addition to refspecs explicitly listed on the command line."

    – jonrsharpe
    Nov 21 '18 at 16:13













  • Possible duplicate of Cannot push to GitHub - keeps saying need merge

    – phd
    Nov 21 '18 at 16:46






  • 1





    stackoverflow.com/…

    – phd
    Nov 21 '18 at 16:46











  • The problem has nothing with tags, it's a problem with non-fast-forward push of master. Run git push origin master and you will get the same error.

    – phd
    Nov 21 '18 at 16:46













  • @jonrsharpe Ahh, that does make a whole lot of sense. Thanks. My first command does push all tags and the second one pushes all tags and the ref specified... I've read through the push docs so often and never really read the whole sentence.

    – Daniel Habenicht
    Nov 21 '18 at 17:00










1




1





See the docs, that's what they say it does: "...in addition to refspecs explicitly listed on the command line."

– jonrsharpe
Nov 21 '18 at 16:13







See the docs, that's what they say it does: "...in addition to refspecs explicitly listed on the command line."

– jonrsharpe
Nov 21 '18 at 16:13















Possible duplicate of Cannot push to GitHub - keeps saying need merge

– phd
Nov 21 '18 at 16:46





Possible duplicate of Cannot push to GitHub - keeps saying need merge

– phd
Nov 21 '18 at 16:46




1




1





stackoverflow.com/…

– phd
Nov 21 '18 at 16:46





stackoverflow.com/…

– phd
Nov 21 '18 at 16:46













The problem has nothing with tags, it's a problem with non-fast-forward push of master. Run git push origin master and you will get the same error.

– phd
Nov 21 '18 at 16:46







The problem has nothing with tags, it's a problem with non-fast-forward push of master. Run git push origin master and you will get the same error.

– phd
Nov 21 '18 at 16:46















@jonrsharpe Ahh, that does make a whole lot of sense. Thanks. My first command does push all tags and the second one pushes all tags and the ref specified... I've read through the push docs so often and never really read the whole sentence.

– Daniel Habenicht
Nov 21 '18 at 17:00







@jonrsharpe Ahh, that does make a whole lot of sense. Thanks. My first command does push all tags and the second one pushes all tags and the ref specified... I've read through the push docs so often and never really read the whole sentence.

– Daniel Habenicht
Nov 21 '18 at 17:00














1 Answer
1






active

oldest

votes


















1















I am asking why the command is trying to push the branch to the remote and not why it is being rejected,




Because git push will push new commits and (with --tags) new tags.




  • C is already pushed so nothing to push there

  • the new tag is pushed.


In your second case, you are trying to reset the remote master branch (which is at D) to C (in addition of pushing tags).






share|improve this answer
























  • Thanks for clarifying.

    – Daniel Habenicht
    Nov 22 '18 at 19:49











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416198%2fdifference-between-specifying-refspec-with-git-push-tags-or-not%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1















I am asking why the command is trying to push the branch to the remote and not why it is being rejected,




Because git push will push new commits and (with --tags) new tags.




  • C is already pushed so nothing to push there

  • the new tag is pushed.


In your second case, you are trying to reset the remote master branch (which is at D) to C (in addition of pushing tags).






share|improve this answer
























  • Thanks for clarifying.

    – Daniel Habenicht
    Nov 22 '18 at 19:49
















1















I am asking why the command is trying to push the branch to the remote and not why it is being rejected,




Because git push will push new commits and (with --tags) new tags.




  • C is already pushed so nothing to push there

  • the new tag is pushed.


In your second case, you are trying to reset the remote master branch (which is at D) to C (in addition of pushing tags).






share|improve this answer
























  • Thanks for clarifying.

    – Daniel Habenicht
    Nov 22 '18 at 19:49














1












1








1








I am asking why the command is trying to push the branch to the remote and not why it is being rejected,




Because git push will push new commits and (with --tags) new tags.




  • C is already pushed so nothing to push there

  • the new tag is pushed.


In your second case, you are trying to reset the remote master branch (which is at D) to C (in addition of pushing tags).






share|improve this answer














I am asking why the command is trying to push the branch to the remote and not why it is being rejected,




Because git push will push new commits and (with --tags) new tags.




  • C is already pushed so nothing to push there

  • the new tag is pushed.


In your second case, you are trying to reset the remote master branch (which is at D) to C (in addition of pushing tags).







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 18:34









VonCVonC

834k29026263170




834k29026263170













  • Thanks for clarifying.

    – Daniel Habenicht
    Nov 22 '18 at 19:49



















  • Thanks for clarifying.

    – Daniel Habenicht
    Nov 22 '18 at 19:49

















Thanks for clarifying.

– Daniel Habenicht
Nov 22 '18 at 19:49





Thanks for clarifying.

– Daniel Habenicht
Nov 22 '18 at 19:49


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53416198%2fdifference-between-specifying-refspec-with-git-push-tags-or-not%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Create new schema in PostgreSQL using DBeaver

Deepest pit of an array with Javascript: test on Codility

Costa Masnaga