You have to perform a full repository checkout in your workflow job in order to get the full repository data (including all branches). When you do
git clone... (without any switches like
--single-branch) on your local machine you are getting all the repository data (tags, branches, commit history, etc.). This is why
git branch -r command output contains all the remote branches.
In GitHub Actions (or mentioned Travis CI) the clone operation behaves slightly different. By default, to conserve bandwidth and disk storage space the CI system retrieves only the minimal required part of the repository in order to execute the workflow. This usually is only the current branch associated with the workflow and limited commit history. This is why your commands do not return all the expected branches. However, you can override the default checkout behaviour. If you look at the
Only a single commit is fetched by default, for the ref/SHA that triggered the workflow. Set
fetch-depth: 0to fetch all history for all branches and tags.
Fetch all history for all tags and branches
- uses: actions/[email protected] with: fetch-depth: 0
Now, when you call in the next step sth. like:
- name: List all the remote branches run: git branch -r
you should get the expected output.
git: depth: false
CLICK HERE to find out more related problems solutions.