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.
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:
🔹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
🔹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
🔹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.
🔹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