This guide helps you set up and configure Git with GitHub. For video tutorial, see Connecting Git to Github in 8 minutes.
Ensure you have Git installed on your system.
First, create two directories for your GitHub projects:
# Create first directory
mkdir -p directory1
# Navigate into it
cd directory1
# Create second directory for GitHub repo
mkdir -p directory2Navigate to your project directory and initialize Git:
git initSet your Git username and email:
git config --global user.name "USER_NAME"
git config --global user.email "YOUR-EMAIL.com"# Add remote repository
git remote add origin https://github.com/USER-NAME/repository.git
# Verify remote connection
git remote -v
# Authenticate with personal access token
git remote set-url origin https://USER_NAME:[email protected]/USER-NAME/repository.git# Fetch all branches and history
git fetch origin
# View commit history
git log
# Switch branches
git switch main
# List branches
git branch
# Pull changes from remote
git pull origin# Stage all changes
git add .
# Commit changes with message
git commit -m "commit message"
# Push changes to remote repository
git push origin master
# Pull latest changes from remote
git pull origin masterTo automatically set up remote tracking, configure Git globally:
git config --global push.autoSetupRemote trueOr manually set upstream:
git push --set-upstream origin master# View repository status
git status
# View commit history
git logCopyright (C) 2025 by Yididiel Hills All rights reserved [email protected].