Alex Xu Profile picture
Co-Founder of ByteByteGo | Author of the bestselling book series: ‘System Design Interview’ | YouTube: https://t.co/9gPSJSrtPU

Feb 6, 2023, 9 tweets

/1 Git Workflow & Immutability

Immutability here means that once data is written into Git, it cannot be changed. Modifications only create new data versions. The old data remains unchanged.

/2 Immutable system designs are commonly used in systems that require high levels of auditability, such as financial systems and version control systems. Here's how it's used in Git design:

/3 🔹Users' local Git storage consists of three sections: working copy, staging area, and local repository.
🔹Working copies contain the files you are currently working on. The data is mutable, so you can do whatever you want with it

/4 🔹When you type "git add", your files will be added to the staging area. These files are now immutable. It is no longer possible to edit them

/5 🔹When you type "git commit", your staging files are added to the local repository. Local repository is a tree version of the append-only write-ahead log (WAL). They are both immutable: you can only append to the end of the data structure.

/6 🔹When you type "git push", your local repository data will be synced to the remote repository. As the remote repository uses the same data structure as your local repository, it is also immutable: you can only add data to it

/7 👉 Over to you: there are two ways to save the history of a file: either save every version of the file, or save every delta change to the file and reconstruct the file by aggregating all delta changes. Would you recommend Git using one over another, and why?

/8 Subscribe to our weekly free newsletter to learn something new every week: bit.ly/3FEGliw

/9 I hope you've found this thread helpful.

Follow me @alexxubyte for more.

Like/Retweet the first tweet below if you can:

Share this Scrolly Tale with your friends.

A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.

Keep scrolling