✅ Quick Summary

The Trees API lets you build an entire directory tree of blobs (file contents) in memory, attach it to a single commit, and update the branch reference once. This means all files land in exactly one commit, atomically.

The Problem

The naive approach — using the Contents API to create or update each file individually — requires one API call per file and creates one commit per file, which is both slow and pollutes your commit history.

How Push44 Solves It

The Trees API lets you build an entire directory tree of blobs (file contents) in memory, attach it to a single commit, and update the branch reference once. This means all files land in exactly one commit, atomically.

Step-by-Step Guide

1

Create blobs for each file

Every file's content is uploaded as a 'blob' object via the Git Data API, returning a SHA hash for each.

2

Build a tree

A 'tree' object is created that maps every file path to its blob SHA, recreating your project's folder structure exactly.

3

Create a commit

A commit object is created that points to the new tree and references the previous commit as its parent, preserving history.

4

Update the branch reference

Finally, the branch pointer (e.g. 'refs/heads/main') is updated to point at the new commit — this is the single step that makes the push visible on GitHub.

5

Handle empty repositories separately

Brand new repos with no commits yet don't have a HEAD reference, so Push44 detects this case and creates the very first commit differently before switching to the standard tree-based flow.

Pro Tips

  • This is the same technique used by advanced git tooling for bulk file operations — Push44 brings it to a no-code UI.
  • Because the branch reference update is the last step, your repo is never left in a half-pushed state.

Common Mistakes to Avoid

⚠️ Watch Out For
  • Assuming a failed export means partial data was written — with the Trees API, nothing is visible until the very last step succeeds.

Ready to Export?

Push44 is free, open source, and takes under 2 minutes to set up.

Frequently Asked Questions

Does this approach work for repositories with hundreds of files?
Yes. The Trees API is designed for exactly this — GitHub itself uses similar tooling internally for bulk operations.
Why does my commit show all files as 'added' the first time?
On your very first push to a new (or empty) repository, there's no prior tree to diff against, so every file appears as added in that first commit.