Salesforce, Python, SQL, & other ways to put your data where you need it

Need event music? 🎸

Live and recorded jazz, pop, and meditative music for your virtual conference / Zoom wedding / yoga class / private party with quality sound and a smooth technical experience

Fill an empty cloud-hosted Git repository

01 Mar 2024 🔖 tutorials git
💬 EN

Table of Contents

Imagine that you’ve created an empty Git repository (you asked the setup wizard not to auto-generate any files like README.md or .gitignore) within a cloud-based hosting service like GitHub, Atlassian BitBucket, GitLab, Azure DevOps Repos, AWS CodeCommit, GCP Cloud Source Repositories, OCI DCS Repositories, etc.

How do you set yourself up so that you can add a file or few to it?

Let’s take a look at some of your options.


Through the host’s web portal file explorer

Many Git cloud hosts (see the list of examples above) offer a web-browser-based interface for exploring the files (and file history) contained in the copy of a Git repository that the service is responsible for hosting. While most interfaces include buttons for adding, removing, editing, and renaming files, only a few of those web interfaces work correctly against an empty repository with no files in its commit history.

Note: Furthermore, I feel that instructions for cloning a cloud-hosted Git repository onto a desktop computer are typically better-documented, and involve easier-to-use tooling, than instructions for publishing a desktop-hosted Git repository into a cloud host.

Tip: Therefore, when you create a new repository in your cloud host, strongly consider letting the cloud host populate it with a file such as README.md or .gitignore so that you don’t have to deal with an empty cloud-hosted repository in the first place.

Web editor availability:

  • GitHub - managing files works on empty repositories.
    • Repositories hosted in GitHub can also be edited with web-based power tools VSCode.dev and GitHub.dev, but only once they are no longer empty.
  • BitBucket does not come with an option to add your first file to an empty repository through the web browser.
  • GitLab - web editor possibly works on empty repositories?
  • Azure DevOps Repos does not come with an option to add your first file to an empty repository through the web browser.
    • Repositories hosted in Azure Repos can also be edited with web-based power tool VSCode.dev, but only once they are no longer empty.
  • AWS CodeCommit - working with files seems to work on empty repositories, according to a random StackOverflow contributor.

TODO: All this is junk so far

From your desktop computer

With the Git command line

Cheating by making it not empty

  1. Use one of the web-based approaches above to put a file such as README.md or a .gitignore into the cloud-hosted copy of the repository.
  2. Download a copy of the no-longer-empty cloud-hosted repository into a folder of your choice on your desktop computer (e.g. C:\example\) with the git clone command.
    • If you already cloned it a while ago, run the git pull command to make sure your computer’s copy of the repository is up-to-date with the cloud-hosted copy of the repository.
  3. If you are expected to follow your team’s branching and pull request etiquette, then before you start editing any files, please create a new branch and switch over to using it with [the git checkout -b YOUR_NEW_BRANCH_NAME command].
  4. Using your favorite file-editing software, add/edit/remove files in C:\example\ (or whatever folder you chose) and save your work.
  5. Use the git add, git commit, etc. commands when you’re at a nice stopping point that you’d like to put into your official file-change history.
  6. Use the git push -u origin YOUR_NEW_BRANCH_NAME command to upload the “commit” you just made into the cloud-hosted copy of the repository.
    • Note: If you were editing files in a YOUR_NEW_BRANCH_NAME branch instead of the primary branch of the repository (for team etiquette), you’ll have to explore that branch in the cloud host’s web-based file explorer to see your work, and then you’ll have to:
      • Use the cloud host’s web editor’s “pull request” interface to merge your changes into the cloud-hosted copy of the primary branch of the repository.
      • Delete the YOUR_NEW_BRANCH_NAME branch both out of the cloud-hosted copy of your repository (if it’s still there after merging the pull request) and off of your local computer.
  7. Ready to make more edits? Repeat from step 2 (using git pull instead of git clone).

Truly doing it the hard way

With VSCode

With GitHub Desktop

--- ---