How not to ignore the message “not found in upstream origin, using HEAD instead”?












2














I am writing shell script to deploy a git branch from a remote repo.



This is the command I am using:



   git clone -q --depth=1 https://my.repourl.com/git-repo.git /my/destination/folder -b develop


The problem is, if the branch (develop in this case) is wrong, it just ignores and pulls from the master branch (?). I get this message:



  warning: Remote branch devel not found in upstream origin, using HEAD instead


I just want git to die/exit, if it does not find the branch specified. Any flags for that?
Or any alternatives? git-archive did not work for some reason.










share|improve this question






















  • Parse the output from git ls-remote first to make sure the branch exists?
    – twalberg
    Mar 13 '13 at 19:11
















2














I am writing shell script to deploy a git branch from a remote repo.



This is the command I am using:



   git clone -q --depth=1 https://my.repourl.com/git-repo.git /my/destination/folder -b develop


The problem is, if the branch (develop in this case) is wrong, it just ignores and pulls from the master branch (?). I get this message:



  warning: Remote branch devel not found in upstream origin, using HEAD instead


I just want git to die/exit, if it does not find the branch specified. Any flags for that?
Or any alternatives? git-archive did not work for some reason.










share|improve this question






















  • Parse the output from git ls-remote first to make sure the branch exists?
    – twalberg
    Mar 13 '13 at 19:11














2












2








2


1





I am writing shell script to deploy a git branch from a remote repo.



This is the command I am using:



   git clone -q --depth=1 https://my.repourl.com/git-repo.git /my/destination/folder -b develop


The problem is, if the branch (develop in this case) is wrong, it just ignores and pulls from the master branch (?). I get this message:



  warning: Remote branch devel not found in upstream origin, using HEAD instead


I just want git to die/exit, if it does not find the branch specified. Any flags for that?
Or any alternatives? git-archive did not work for some reason.










share|improve this question













I am writing shell script to deploy a git branch from a remote repo.



This is the command I am using:



   git clone -q --depth=1 https://my.repourl.com/git-repo.git /my/destination/folder -b develop


The problem is, if the branch (develop in this case) is wrong, it just ignores and pulls from the master branch (?). I get this message:



  warning: Remote branch devel not found in upstream origin, using HEAD instead


I just want git to die/exit, if it does not find the branch specified. Any flags for that?
Or any alternatives? git-archive did not work for some reason.







git shell deployment warnings clone






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 13 '13 at 18:01









Kevin RaveKevin Rave

4,9132577133




4,9132577133












  • Parse the output from git ls-remote first to make sure the branch exists?
    – twalberg
    Mar 13 '13 at 19:11


















  • Parse the output from git ls-remote first to make sure the branch exists?
    – twalberg
    Mar 13 '13 at 19:11
















Parse the output from git ls-remote first to make sure the branch exists?
– twalberg
Mar 13 '13 at 19:11




Parse the output from git ls-remote first to make sure the branch exists?
– twalberg
Mar 13 '13 at 19:11












2 Answers
2






active

oldest

votes


















1














As twalberg comments, git ls-remote --heads https://my.repourl.com/git-repo.git is the command to use for checking if a branch exists on the remote side.



The question "How to check if remote branch exists on a given remote repository?" lists the other possibility:



git clone -n
git fetch
# parse git branch -r




The test (bash) can look like:



br=$(git ls-remote --heads https://my.repourl.com/git-repo.git|grep abranch)
if [[ "${br}" != "" ]]; then
git clone -b aBranch ...
fi





share|improve this answer























  • Well, I have to do this in Shell Script and check the status of each command (success/fail). But the question actually how NOT to ignore warnings when branch does not exist when cloning?
    – Kevin Rave
    Mar 13 '13 at 20:01






  • 2




    @KevinRave and the answer is to not clone because you have detected before that the branch doesn't exist.
    – VonC
    Mar 13 '13 at 20:32










  • I got your point. So this is going to be done in two steps. Check if repo and branch exist and then do a clone, if branch exists. I thought if I could do this in one shot. :-)
    – Kevin Rave
    Mar 13 '13 at 20:46












  • BTW, can you elaborate your answer and write the git commands completely, so that it is useful to others?
    – Kevin Rave
    Mar 13 '13 at 20:48










  • @KevinRave answer edited
    – VonC
    Mar 13 '13 at 21:01



















0














I'm getting the same behavior as posted by Kevin with git v1.7.1 - but when testing with git v2.12.0, the clone command does actually fail when a non-existing branch is specified :



$ git clone --depth 1 -b FakeBranch --bare gitserver:/repo.git
Cloning into bare repository 'repo.git'...
warning: Could not find remote branch FakeBranch to clone.
fatal: Remote branch FakeBranch not found in upstream origin





share|improve this answer





















  • It seems to be the case since 1.7.10: github.com/git/git/commit/…
    – VonC
    Nov 23 '18 at 18:09











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%2f15393004%2fhow-not-to-ignore-the-message-not-found-in-upstream-origin-using-head-instead%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














As twalberg comments, git ls-remote --heads https://my.repourl.com/git-repo.git is the command to use for checking if a branch exists on the remote side.



The question "How to check if remote branch exists on a given remote repository?" lists the other possibility:



git clone -n
git fetch
# parse git branch -r




The test (bash) can look like:



br=$(git ls-remote --heads https://my.repourl.com/git-repo.git|grep abranch)
if [[ "${br}" != "" ]]; then
git clone -b aBranch ...
fi





share|improve this answer























  • Well, I have to do this in Shell Script and check the status of each command (success/fail). But the question actually how NOT to ignore warnings when branch does not exist when cloning?
    – Kevin Rave
    Mar 13 '13 at 20:01






  • 2




    @KevinRave and the answer is to not clone because you have detected before that the branch doesn't exist.
    – VonC
    Mar 13 '13 at 20:32










  • I got your point. So this is going to be done in two steps. Check if repo and branch exist and then do a clone, if branch exists. I thought if I could do this in one shot. :-)
    – Kevin Rave
    Mar 13 '13 at 20:46












  • BTW, can you elaborate your answer and write the git commands completely, so that it is useful to others?
    – Kevin Rave
    Mar 13 '13 at 20:48










  • @KevinRave answer edited
    – VonC
    Mar 13 '13 at 21:01
















1














As twalberg comments, git ls-remote --heads https://my.repourl.com/git-repo.git is the command to use for checking if a branch exists on the remote side.



The question "How to check if remote branch exists on a given remote repository?" lists the other possibility:



git clone -n
git fetch
# parse git branch -r




The test (bash) can look like:



br=$(git ls-remote --heads https://my.repourl.com/git-repo.git|grep abranch)
if [[ "${br}" != "" ]]; then
git clone -b aBranch ...
fi





share|improve this answer























  • Well, I have to do this in Shell Script and check the status of each command (success/fail). But the question actually how NOT to ignore warnings when branch does not exist when cloning?
    – Kevin Rave
    Mar 13 '13 at 20:01






  • 2




    @KevinRave and the answer is to not clone because you have detected before that the branch doesn't exist.
    – VonC
    Mar 13 '13 at 20:32










  • I got your point. So this is going to be done in two steps. Check if repo and branch exist and then do a clone, if branch exists. I thought if I could do this in one shot. :-)
    – Kevin Rave
    Mar 13 '13 at 20:46












  • BTW, can you elaborate your answer and write the git commands completely, so that it is useful to others?
    – Kevin Rave
    Mar 13 '13 at 20:48










  • @KevinRave answer edited
    – VonC
    Mar 13 '13 at 21:01














1












1








1






As twalberg comments, git ls-remote --heads https://my.repourl.com/git-repo.git is the command to use for checking if a branch exists on the remote side.



The question "How to check if remote branch exists on a given remote repository?" lists the other possibility:



git clone -n
git fetch
# parse git branch -r




The test (bash) can look like:



br=$(git ls-remote --heads https://my.repourl.com/git-repo.git|grep abranch)
if [[ "${br}" != "" ]]; then
git clone -b aBranch ...
fi





share|improve this answer














As twalberg comments, git ls-remote --heads https://my.repourl.com/git-repo.git is the command to use for checking if a branch exists on the remote side.



The question "How to check if remote branch exists on a given remote repository?" lists the other possibility:



git clone -n
git fetch
# parse git branch -r




The test (bash) can look like:



br=$(git ls-remote --heads https://my.repourl.com/git-repo.git|grep abranch)
if [[ "${br}" != "" ]]; then
git clone -b aBranch ...
fi






share|improve this answer














share|improve this answer



share|improve this answer








edited May 23 '17 at 12:21









Community

11




11










answered Mar 13 '13 at 19:47









VonCVonC

832k29026183161




832k29026183161












  • Well, I have to do this in Shell Script and check the status of each command (success/fail). But the question actually how NOT to ignore warnings when branch does not exist when cloning?
    – Kevin Rave
    Mar 13 '13 at 20:01






  • 2




    @KevinRave and the answer is to not clone because you have detected before that the branch doesn't exist.
    – VonC
    Mar 13 '13 at 20:32










  • I got your point. So this is going to be done in two steps. Check if repo and branch exist and then do a clone, if branch exists. I thought if I could do this in one shot. :-)
    – Kevin Rave
    Mar 13 '13 at 20:46












  • BTW, can you elaborate your answer and write the git commands completely, so that it is useful to others?
    – Kevin Rave
    Mar 13 '13 at 20:48










  • @KevinRave answer edited
    – VonC
    Mar 13 '13 at 21:01


















  • Well, I have to do this in Shell Script and check the status of each command (success/fail). But the question actually how NOT to ignore warnings when branch does not exist when cloning?
    – Kevin Rave
    Mar 13 '13 at 20:01






  • 2




    @KevinRave and the answer is to not clone because you have detected before that the branch doesn't exist.
    – VonC
    Mar 13 '13 at 20:32










  • I got your point. So this is going to be done in two steps. Check if repo and branch exist and then do a clone, if branch exists. I thought if I could do this in one shot. :-)
    – Kevin Rave
    Mar 13 '13 at 20:46












  • BTW, can you elaborate your answer and write the git commands completely, so that it is useful to others?
    – Kevin Rave
    Mar 13 '13 at 20:48










  • @KevinRave answer edited
    – VonC
    Mar 13 '13 at 21:01
















Well, I have to do this in Shell Script and check the status of each command (success/fail). But the question actually how NOT to ignore warnings when branch does not exist when cloning?
– Kevin Rave
Mar 13 '13 at 20:01




Well, I have to do this in Shell Script and check the status of each command (success/fail). But the question actually how NOT to ignore warnings when branch does not exist when cloning?
– Kevin Rave
Mar 13 '13 at 20:01




2




2




@KevinRave and the answer is to not clone because you have detected before that the branch doesn't exist.
– VonC
Mar 13 '13 at 20:32




@KevinRave and the answer is to not clone because you have detected before that the branch doesn't exist.
– VonC
Mar 13 '13 at 20:32












I got your point. So this is going to be done in two steps. Check if repo and branch exist and then do a clone, if branch exists. I thought if I could do this in one shot. :-)
– Kevin Rave
Mar 13 '13 at 20:46






I got your point. So this is going to be done in two steps. Check if repo and branch exist and then do a clone, if branch exists. I thought if I could do this in one shot. :-)
– Kevin Rave
Mar 13 '13 at 20:46














BTW, can you elaborate your answer and write the git commands completely, so that it is useful to others?
– Kevin Rave
Mar 13 '13 at 20:48




BTW, can you elaborate your answer and write the git commands completely, so that it is useful to others?
– Kevin Rave
Mar 13 '13 at 20:48












@KevinRave answer edited
– VonC
Mar 13 '13 at 21:01




@KevinRave answer edited
– VonC
Mar 13 '13 at 21:01













0














I'm getting the same behavior as posted by Kevin with git v1.7.1 - but when testing with git v2.12.0, the clone command does actually fail when a non-existing branch is specified :



$ git clone --depth 1 -b FakeBranch --bare gitserver:/repo.git
Cloning into bare repository 'repo.git'...
warning: Could not find remote branch FakeBranch to clone.
fatal: Remote branch FakeBranch not found in upstream origin





share|improve this answer





















  • It seems to be the case since 1.7.10: github.com/git/git/commit/…
    – VonC
    Nov 23 '18 at 18:09
















0














I'm getting the same behavior as posted by Kevin with git v1.7.1 - but when testing with git v2.12.0, the clone command does actually fail when a non-existing branch is specified :



$ git clone --depth 1 -b FakeBranch --bare gitserver:/repo.git
Cloning into bare repository 'repo.git'...
warning: Could not find remote branch FakeBranch to clone.
fatal: Remote branch FakeBranch not found in upstream origin





share|improve this answer





















  • It seems to be the case since 1.7.10: github.com/git/git/commit/…
    – VonC
    Nov 23 '18 at 18:09














0












0








0






I'm getting the same behavior as posted by Kevin with git v1.7.1 - but when testing with git v2.12.0, the clone command does actually fail when a non-existing branch is specified :



$ git clone --depth 1 -b FakeBranch --bare gitserver:/repo.git
Cloning into bare repository 'repo.git'...
warning: Could not find remote branch FakeBranch to clone.
fatal: Remote branch FakeBranch not found in upstream origin





share|improve this answer












I'm getting the same behavior as posted by Kevin with git v1.7.1 - but when testing with git v2.12.0, the clone command does actually fail when a non-existing branch is specified :



$ git clone --depth 1 -b FakeBranch --bare gitserver:/repo.git
Cloning into bare repository 'repo.git'...
warning: Could not find remote branch FakeBranch to clone.
fatal: Remote branch FakeBranch not found in upstream origin






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 23 '18 at 11:09









user1564286user1564286

847




847












  • It seems to be the case since 1.7.10: github.com/git/git/commit/…
    – VonC
    Nov 23 '18 at 18:09


















  • It seems to be the case since 1.7.10: github.com/git/git/commit/…
    – VonC
    Nov 23 '18 at 18:09
















It seems to be the case since 1.7.10: github.com/git/git/commit/…
– VonC
Nov 23 '18 at 18:09




It seems to be the case since 1.7.10: github.com/git/git/commit/…
– VonC
Nov 23 '18 at 18:09


















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.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • 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%2f15393004%2fhow-not-to-ignore-the-message-not-found-in-upstream-origin-using-head-instead%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

Trompette piccolo

Slow SSRS Report in dynamic grouping and multiple parameters

Simon Yates (cyclisme)