Git is a free, open-source version control system that tracks changes to files, so you can see what changed, when, and who changed it. It lets you save snapshots of your project called commits, roll back to earlier versions, and create branches to try out new ideas without messing up the main code. Because it's distributed, every developer has a full copy of the project history on their own machine, which means you can work offline and merge your changes with others' work later.
Key Git syntax:
Git pull
Fetches the latest changes from the remote repository (like GitHub) and merges them into the branch you're currently on, so your local copy stays up to date with what your teammates have pushed
Git switch -c <branch name>
Creates a new branch with the name you give it and immediately switches you onto it, all in one step
Git add .
Stages all the new, modified, and deleted files in your current directory (and its subdirectories) so they're ready to be included in your next commit. It doesn't save anything to your history yet; it just tells Git, "these are the changes I want in the next snapshot."
Git commit -m “<your message>”
Takes everything you've staged with git add and saves it as a new commit in your project history, with the text in quotes serving as the commit message
Git push origin <your branch>
Uploads your local commits on that branch to the remote repository named origin (usually your GitHub repo), so your teammates can see and build on your work.
Git branch -d <your-branch>
Is the safe way to delete a local branch. Git will only remove it if its commits have already been merged into your current branch (or its upstream), and if there's unmerged work, it refuses and warns you instead of deleting anything.
