How Do You Create a Master Branch (or First Branch) with the GitHub API?

Problem scenario
You do not want to copy a branch to create a new one. How do you create a branch of a repository that has no branches?

You must know the relevant organization name of the Git repository and the name of the repository itself. Do these changes:

  • Change "acme" to the organization name
  • Change "goodrepo" to the repository name of your choice.
  • Change "jdoe" to the user for GitHub
  • Change "securepassword" to the password for the above user
git clone$ORGNAME/$REPONAME.git
echo "This file was added automatically." > file3.txt
git add file3.txt
git commit -m "Added a file to the repository."
git push https://$user:$$ORGNAME/$REPONAME.git

Leave a comment

Your email address will not be published. Required fields are marked *