Committing code directly from a local disk to a GitHub repository is an essential skill for productivity. This guide covers how to install, configure, and use Git Bash on Windows 10, including managing large files with Git LFS.
cd /c/git-projects
Before you start committing, configure your global username and email:
git config --global user.name "your_username"
git config --global user.email "your_email@example.com"
If you have an existing repository on GitHub:
# Clone the repository
git clone https://github.com/user/testgit.git
cd testgit
# Check status and add files
git status
git add test.txt
# Commit and push
git commit -m "Initial commit"
git push -u origin main
If you’ve made changes directly on GitHub (in the browser), your local version will be behind. If you try to push local changes, it will be rejected. To fix this:
git pull origin main
This command pulls the latest changes and merges them into your local branch. After resolving any conflicts, you can push your changes.
Standard Git is not optimized for large files (like videos or large datasets). Git Large File Storage (LFS) handles this by storing references in Git while keeping the actual files on a separate server.
# Install and initialize LFS
sudo apt update && sudo apt install git-lfs # On WSL
git lfs install
# Initialize a new repo or go to an existing one
git init
# Track specific file types (e.g., .mp4) or a specific file
git lfs track "*.mp4"
git lfs track "large_dataset.csv"
# Add the configuration file and commit
git add .gitattributes
git commit -m "Configure Git LFS for tracking large files"
# Add the large files and push
git add video.mp4 large_dataset.csv
git commit -m "Add large media and data files"
git push origin main
Last Updated: Jul 20 2023.
Powered by Jekyll and Minimal Light theme.