Creating and Managing a GitHub Repository

A practical guide from local setup to GitHub push

Git
GitHub
Version Control
Data Science
Step-by-step guide to creating a local Git repository, linking it to GitHub, and pushing changes.
Author

Nivedita Bhadra

Published

July 1, 2025

Diagram showing a local Git repository pushing commits to a GitHub remote, with a commit history timeline

The core workflow this tutorial covers: initialize locally, commit your work, and push it to a hosted GitHub remote.

Version control is the foundation of any reproducible project, whether you’re managing a single analysis script or a multi-contributor codebase. This tutorial walks through the complete lifecycle of a Git-tracked project — from initializing a local repository to hosting it on GitHub and keeping the two in sync. Every command below is copy-paste ready for your terminal.

Git installed GitHub account Terminal access


Create a New Local Project

mkdir my_project                  # Create project folder
cd my_project                     # Navigate into folder
git init                          # Initialize Git
echo "# My Project" >> README.md  # Create a README file
git add README.md                 # Stage file
git commit -m "Initial commit"    # Commit file

Push Code to GitHub

git branch -M main                # Ensure branch is 'main'
git push -u origin main           # Push to GitHub

Update Changes to GitHub Later

When you make changes locally:

git status                        # Check modified files
git add .                         # Stage all changes
git commit -m "Describe your changes here"
git push                          # Push updates to GitHub

Clone an Existing Repository (Optional)

If you want to work on an existing repo:

git clone https://github.com/<username>/existing_repo.git
cd existing_repo

Make changes, then:

git add .
git commit -m "Updated files"
git push

Next Steps

You now have a fully version-controlled project hosted on GitHub, with a repeatable workflow for committing and pushing future changes. From here, consider exploring branching for parallel feature work, .gitignore for excluding files from version control, or GitHub Actions for automating tests and deployments.

Branching .gitignore GitHub Actions Pull Requests