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 directory2
Navigate to your project directory and initialize Git:
git init
Set 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 master
To automatically set up remote tracking, configure Git globally:
git config --global push.autoSetupRemote true
Or manually set upstream:
git push --set-upstream origin master
# View repository status
git status
# View commit history
git log
Copyright (C) 2025 by Yididiel Hills All rights reserved [email protected].