PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Saturday, July 16, 2022

[FIXED] How not to ignore the message "not found in upstream origin, using HEAD instead"?

 July 16, 2022     clone, deployment, git, shell, warnings     No comments   

Issue

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.


Solution

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


Answered By - VonC
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing