When you encounter the error “cannot publish unborn head” in GitHub Desktop, it typically means that the branch you are trying to push does not have any commits yet. In Git, a branch is considered “unborn” if it has no commits. In order to push a branch to a remote repository, it must have at least one commit.
To resolve this issue, you will need to make an initial commit to the branch before trying to push it again. You can make an initial commit by doing the following:
- Make changes to your local repository: Add or modify files in your local repository.
- Commit your changes: In GitHub Desktop, you will see the changes in the “Changes” tab, you can add a summary and a description for the commit, then click on the “Commit to <branch name>” button.
- Push your changes: Once you have made an initial commit, you should be able to push your changes to the remote repository by clicking on the “Push Origin” button.
Alternatively, you can also run the following command in Git Shell to create an initial commit:
git commit --allow-empty -m "Initial commit"
It’s important to note that it is a good practice to always provide a meaningful commit message when making commits, to help keep track of the changes that were made.