What the Fuck Even is a Git?–Version Control
* tech1. Overview
- Git is a distributed version control system (DVCS) used to track changes in files (typically source code) over time.
- It was created by Linus Torvalds in 2005 for managing the Linux kernel.
- The main idea: every contributor keeps a complete local history of the repository
- Git allows:
- Reverting to any past state of your project.
- Experimenting safely in branches.
- Merging contributions from others.
- Keeping full accountability of who changed what and when.
2. Core Concepts
2.1. Repository (repo)
- A Git repository is like a project folder that contains:
- Your files (the working directory)
- A hidden
.git/folder — where Git stores all history, commits, and branches.
You can create one by running:
git init
2.2. Commit
- A commit is a snapshot of your project at a specific point in time.
- Each commit stores:
- The author and timestamp
- The diff (what changed)
- A parent link (so Git can reconstruct history)
Think of it as a “save point” you can always return to.
git add file.txt git commit -m "Add intro section"
2.3. Branch
- A branch is a parallel timeline of commits.
main(ormaster) is the default branch.You can create branches to work on new features or experiments without disturbing the main code.
git checkout -b feature/awesome-ui
2.4. Merge
- When you’re ready to bring changes from a branch back into another, you merge.
Git compares both histories and applies the differences intelligently (unless conflicts occur).
git checkout main git merge feature/awesome-ui
2.5. Remote
- A remote is a copy of your repo hosted elsewhere (e.g., GitHub, GitLab).
- Remotes make collaboration possible — everyone works locally, then pushes and pulls updates.
My remote repos are available on
git@ssh.tweetor.organd the gitweb is viewable at https://git.tweetor.orggit remote add origin https://github.com/user/project.git git push -u origin main
3. Differences from cloud sync
- Unlike Dropbox or Google Drive, Git:
- Tracks changes, not files.
- Lets you explore history and undo specific edits.
- Merges concurrent changes rather than overwriting them.
4. Typical Workflow
Clone a remote repository (get the full history)
git clone https://github.com/user/project.git
- Create a new branch for your feature
- Edit files, make commits as you go
- Merge your branch back into main
- Push changes to share with others
5. Philosophy
- Git’s philosophy: History is sacred.
- It never throws data away; it just moves pointers.
- The commit graph forms a directed acyclic graph (DAG) — each node is a commit, each edge shows lineage.
- The “current branch” is just a label pointing to the latest commit.
6. Visualization
main: A -- B -- C -- D
\
feature-x: E -- F
- Commits E and F diverged from C; when merged, Git unifies them into a new commit G.
7. Common Pitfalls (and How to Avoid Them)
| Problem | Explanation | Remedy |
|---|---|---|
| Detached HEAD | You checked out a commit, not a branch | `git switch main` |
| Merge Conflict | Git can’t auto-merge same line edits | Manually edit & `git commit` |
| Accidental deletion | Git’s reflog remembers all commits | `git reflog` + `git checkout <hash>` |
8. Why Use Git
- Reliable collaboration tool for any text-based project.
- Enables reproducibility (critical for research and software)(see: What ensures the validity of a scientific investigation?).
- You can build workflows like Org → Git → Publish seamlessly. (see: Org-ref & Org-roam-bibtex Citation Workflow)
9. Further Reading
10. Elsewhere
10.1. References
10.2. In my garden
Notes that link to this note (AKA backlinks).
