Git

🌱 Welcome to the Git Section! Whether you’re learning version control for solo projects or preparing to collaborate with a team, this section will walk you through essential Git commands with hands-on examples. Structured around practical case studies, you’ll explore how to track changes, manage branches, and work with remote repositories—equipping you with the version control skills every programmer needs.

Installation

Please refer to the Data Science Setup to make sure you are up and running!

Summary Table

Summary of the Git section.

Scenario: Create a Project

Concept Example Description
git init git init Initializes a new Git repository
git add git add hello.py Stages a file for commit
git commit git commit -m "message" Saves staged changes with a message
git status git status Shows the current state of the repo

Scenario: Branches

Concept Example Description
git checkout -b git checkout -b add-greeting Creates and switches to a new branch
git add git add hello.py Stages changes for commit
git commit git commit -m "Add feature" Commits staged changes with a message
git checkout git checkout main Switches back to the main branch
git merge git merge add-greeting Merges the feature branch into the main branch
git branch -d git branch -d add-greeting Deletes the feature branch after merging

Scenario: Collaboration

Concept Example Description
git clone git clone https://github.com/user/project Copies a remote repository to local machine
git pull git pull Fetches and merges changes from the remote repo
git add git add . Stages all changed files
git commit git commit -m "Update documentation" Commits changes with a descriptive message
git push git push Uploads local commits to the remote repository