How not to ignore the message “not found in upstream origin, using HEAD instead”?
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
add a comment |
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
Parse the output fromgit ls-remote
first to make sure the branch exists?
– twalberg
Mar 13 '13 at 19:11
add a comment |
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
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
git shell deployment warnings clone
asked Mar 13 '13 at 18:01
Kevin RaveKevin Rave
4,9132577133
4,9132577133
Parse the output fromgit ls-remote
first to make sure the branch exists?
– twalberg
Mar 13 '13 at 19:11
add a comment |
Parse the output fromgit 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
add a comment |
2 Answers
2
active
oldest
votes
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
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 thegit
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
|
show 1 more comment
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
It seems to be the case since 1.7.10: github.com/git/git/commit/…
– VonC
Nov 23 '18 at 18:09
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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 thegit
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
|
show 1 more comment
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
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 thegit
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
|
show 1 more comment
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
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
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 thegit
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
|
show 1 more comment
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 thegit
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
|
show 1 more comment
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
It seems to be the case since 1.7.10: github.com/git/git/commit/…
– VonC
Nov 23 '18 at 18:09
add a comment |
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
It seems to be the case since 1.7.10: github.com/git/git/commit/…
– VonC
Nov 23 '18 at 18:09
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
Parse the output from
git ls-remote
first to make sure the branch exists?– twalberg
Mar 13 '13 at 19:11