Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cannot use git commands inside a step

Arnaud Bosc
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 28, 2020

Hi,

I keep getting the error `fatal: Not a valid object name master` on commands that use git. Even when fetching all refs in the same step or just before the command.

Any ideas? :)

1 answer

1 accepted

2 votes
Answer accepted
ktomk
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 8, 2020

The git error "fatal: Not a valid object name master" shows that the local repository has no branch named "master". That branch is important as it is the main branch name for git and some git commands depend on it, e.g. the one that fails in your case.

This is despite you fetched all the remote references (incl. the branches and especially the remote master branch) because all remote branches are prefixed with remote/<remote-name>/<remote-branch-name> in the local repository.

To fetch the remote master branch as the local master branch to create it locally as well, use git fetch:

git fetch origin master:master

Do this before the git command that previously failed and it should work. 

References:

Arnaud Bosc
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 9, 2020

Thanks a lot @ktomk !

That's indeed the proper answer. I used to try to fetch references using the remote syntax instead.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events