A branch in Git is simply a lightweight movable pointer to one of the commits. The default branch name in Git is master. As you start making commits, you’re given a master branch that points to the last commit you made. Every time you commit, the master branch pointer moves forward automatically. The “master” branch in Git is not a special branch. It is exactly like any other branch. The only reason nearly every repository has one is that the git init command creates it by default and most people don’t bother to change it. Kindly refer to these related guides: How to install, register and start GitLab Runner on Windows, Panic: Failed to register the GitLab-runner, you may be having network issues, how to clone a repository and install software from GitHub on Windows, how to install and uninstall Docker Desktop on Windows 10 and Windows Server, and how to install Git on macOS.
If you wish to changes the defautlt branch, here are the steps in renaming the default branch. These steps will be discussed in details in a different guide; - Change the branch name - Set remote upstream tracking for the new branch - Change the new branch name in repo host.
The following error below will be prompted when you are running a pipeline job in Git. For this specific scenario, this error was prompted because I use using “master” instead of on main as the default branch name. You can see from the image below, various hinds were given. With these hints, I was able to resolve the issue very quickly. Kindly refer to this related error: Cannot lock ref ‘refs/remotes/origin/windows’: unable to resolve reference ‘refs/remotes/origin/windows’, Not a directory!
Solution: This error can be resolved in different ways but understanding your environment will help.
In my case, I had to set
git config --global init.defaultBranch main as suggested in “line 18” in the image above. The default branch’s name is main, not master.
git config --global init.defaultBranch main
After changing the git init default branch name, as shown above, the issue was resolved. If you are still having these errors after using the right branch name, please follow the steps below.
If the branch name is correct, then you will have to prune the origin. This will do is remove references to remote branches in the folder
.git/refs/remotes/origin. So this will not affect your local branches and it will not change anything remotely, but it will update the local references you have to remote branches.
git remote prune origin
If none of these solutions work, please visit the following link for further steps. I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.