Git
Git is a distributed version control system (VCS) that tracks changes in project files and supports collaborative workflows with lightweight branching and remotes.
Installation and Setup
Install the CLI with your platform tools, then set your identity:
Key Features
- Distributed model with full local history, offline commits, and cheap clones.
- Fast branching and merging that enable short lived feature branches and code review.
- Staging area that lets you craft commits by selecting exact changes.
- Remote workflows for collaboration on services like GitHub and GitLab with push, fetch, and pull.
- Advanced tools such as worktrees, submodules, sparse checkout, and signed tags.
Usage
Start a repository and make your first commit:
$ git init
$ echo "# Awesome Python Project" > README.md
$ git add README.md
$ git commit -m "Initial commit"
Connect to a remote and publish:
$ git remote add origin https://example.com/your/repo.git
$ git push -u origin main
Create and switch branches, then merge:
$ git switch -c feature/api
$ # Edit files
$ git add -A
$ git commit -m "Add API"
$ git switch main
$ git merge feature/api
Keep a clean history while syncing:
$ git fetch origin
$ git rebase origin/main
Inspect changes and history:
$ git status
$ git diff
$ git log --oneline --graph --decorate --all
Stash work in progress and restore files:
$ git stash -u
$ git stash pop
$ git restore path/to/file # discard work in a file
$ git restore --staged path/to/file # unstage a file
Tag a release and push tags:
$ git tag -a v1.0.0 -m "First release"
$ git push --follow-tags
Use a Python friendly .gitignore to avoid committing build artifacts and environments.
Related Resources
Tutorial
Introduction to Git and GitHub for Python Developers
What is Git, what is GitHub, and what's the difference? Learn the basics of Git and GitHub from the perspective of a Pythonista in this tutorial.
For additional information on related topics, take a look at the following resources:
- Advanced Git Tips for Python Developers (Tutorial)
- Introduction to Git and GitHub for Python (Course)
By Leodanis Pozo Ramos • Updated Dec. 12, 2025