Version control
Version control gives you some essential capabilities around your codebases & files. The basic idea is “a server somewhere that has a copy of the code you’re working on”.
Where the “versioning” comes in: you can create snapshots of what your codebase looks like at anytime by using commits.
You can easily traverse and retrieve these commits, our point in time snapshots.
More capabilities that git provides:
- Collaborating: Hosting the code on a remote server allows multiple people to work on one project at the same time. A core git concept here is branches.
- Backup & Redundancy of your code
- Application deployment: Keeping your code on a server somewhere allows you to run automations on it.
More git concepts to be aware of
git clone
- creates a local copy of the code from the remote server.git push
- pushes the committed state on my local machine to the servergit pull
- pulls & copies to my local machine the latest commits from the server- related is
git fetch
- fetches the latest commits onto my local machine, but won’t overwrite the files
- related is
- branches
- merging
repository
- if a folder has the hidden sub-directory.git
, it’s likely a git repository.
project-root/
├── .git/
│ ├── objects/
│ ├── refs/
│ └── config
│
├── src/
│ ├── components/
│ └── utils/
│
├── tests/
│
└── README.md
The git workflow I recommend
- Top Level folder: Create a folder where all your code will live.
- Make it a place that’s easy to get to from the terminal. eg
~/code
,~/projects
~/source
- the folder
~/
is/Users/guide/
or/Users/[your username]
- Make it a place that’s easy to get to from the terminal. eg
- Each project exists in it’s own subfolder
~/code/project#1
~/code/project#2
~/code/scraping-project
etc
- Each of these folders is a git repository.
- Start committing early & often, from the get go.
- Use descriptive commit messages
Learning resources
- What is git
- Hackthedegree - The only cheatsheet a Git beginner needs!_
- boot.dev 4 hour git video by ThePrimeagen
- think like a git from start to finish - When you have a few weeks/months of experience with git, I’d recommend.
- Misc: Graph theory
- my notes on git