Home > Enterprise >  Azure DevOps throws error: pathspec 'master' did not match any file(s) known to git
Azure DevOps throws error: pathspec 'master' did not match any file(s) known to git

Time:09-23

We have about 100 running azure-devop pipelines with all the same azure-pipeline.yaml. In all pipelines, we are calling get checkout $(Build.SourceBranchName). In one of the repositories we get the error message:

error: pathspec 'master' did not match any file(s) known to git

On our local machines checking out the master branch does not make any problems. When pushing to any other branch, it is not working as well. E.g. when using dev branch:

error: pathspec 'dev' did not match any file(s) known to git

I can't see any differences. What I tried:

  • Create everything from scratch
  • Check whether HEAD ref is equal to master (origin/master)
  • Creating new branches and push them (e.g. origin/dev) is not working as well
  • Switching branches does not help

Any other ideas?

CodePudding user response:

Same error for me. error: pathspec 'main' did not match any file(s) known to git

Some pipelines fail some others not.

I am using Azure Pipeline Yaml templates for all pipelines and some of the are working and others are failing.

I have tried to create a pipeline from scratch but not success still failing.

git checkout main

git pull

git branch

hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
Initialized empty Git repository in /home/vsts/work/1/s/charts/.git/
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>
git remote add origin https://[email protected]/XXXX/Infrastructure/_git/charts
git config gc.auto 0
git config --get-all http.https://[email protected]/XXXXX/Infrastructure/_git/charts.extraheader
git config --get-all http.extraheader
git config --get-regexp .*extraheader
git config --get-all http.proxy
git config http.version HTTP/1.1
git --config-env=http.extraheader=env_var_http.extraheader fetch --force --tags --prune --prune-tags --progress --no-recurse-submodules origin --depth=1  40cbd1774666ac75618116028750d1ddf7acee22:refs/remotes/origin/40cbd1774666ac75618116028750d1ddf7acee22
remote: Azure Repos      

CodePudding user response:

I would check in that pipeline:

  • git version
  • git branch -avv
  • git switch $(Build.SourceBranchName)

The last command (git switch) would avoid any issue where you checkout a branch which could also be a file name.

  • Related