Github Setup Guide
GitHub Setup Guide for Windows (Git Bash) by Miftah Ahmad Choiri
This guide provides a structured walkthrough to set up GitHub on your PC using Git Bash.
📋 Prerequisites
- Git installed: Download Git
- GitHub account created: Sign up
- GitHub CLI (optional for advanced features): Download GitHub CLI
📄 0. Bash Profile Configuration
cat ~/.bash_profile
export MY_PATH="/c/Users/mifta/OneDrive - IBM/IBM/LEARNING"
alias mydir='cd "$MY_PATH"'
export PATH=$PATH:/c/Program\ Files/GitHub\ CLI
source ~/.bash_profile
This configuration sets a custom path environment and alias for easier navigation and ensures the GitHub CLI is accessible from Git Bash.
🚀 1. Configuring Git
Check Git Version
git --version
Ensure Git is installed correctly.
Set Global Git Configuration
git config --global user.name "miftah-ahmad-choiri"
git config --global user.email "miftahcoiri354@gmail.com"
Verify settings:
git config --list
For organization login:
git config --global user.name "Miftah-Choiri"
git config --global user.email "miftah.choiri@ibm.com"
git config -list
🔐 2. Setting Up SSH for GitHub
Generate SSH Key
ssh-keygen -t ed25519 -C "miftahcoiri354@gmail.com"
Press Enter to accept defaults and optionally set a passphrase.
Start SSH Agent
eval "$(ssh-agent -s)"
Add SSH Key to Agent
ssh-add ~/.ssh/id_ed25519
Add SSH Key to GitHub
- Display the public key:
cat ~/.ssh/id_ed25519.pub
- Copy the key.
- Go to GitHub → Settings → SSH and GPG keys → New SSH key.
- Paste the key and save.
Test SSH Connection
ssh -T git@github.com
Successful output:
Hi miftah-ahmad-choiri! You've successfully authenticated, but GitHub does not provide shell access.
For Organization ssh-connection:
ssh-keygen -t ed25519 -C "miftah.choiri@ibm.com"
# save the key into different location
Enter file in which to save the key (/c/Users/mifta/.ssh/id_ed25519): /c/Users/mifta/.ssh/id_ed25519_ibm
ll ~/.ssh/
vi ~/.ssh/config
# Personal GitHub Account
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
# IBM GitHub Account
Host github.com-ibm
HostName github.ibm.com
User git
IdentityFile ~/.ssh/id_ed25519_ibm
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519_ibm
Identity added: /c/Users/mifta/.ssh/id_ed25519_ibm (miftah.choiri@ibm.com)
Test connection to github.com & github.ibm.com
ssh -i ~/.ssh/id_ed25519_ibm -T git@github.ibm.com
Hi Miftah-Choiri! You've successfully authenticated, but GitHub does not provide shell access.
ssh -T git@github.com
Hi miftah-ahmad-choiri! You've successfully authenticated, but GitHub does not provide shell access.
📦 3. Repository Setup
Initialize a New Git Repository
cd ~/OneDrive - IBM/IBM/LEARNING/github/how-to-setup-github/
git init
Add and Commit Files
git add how-to-setup-github.md
git commit -m "Initial commit"
Add Remote Repository
git branch -M main
git remote add origin git@github.com:miftah-ahmad-choiri/how-to-setup-github.git
gh auth login
gh repo create how-to-setup-github --public --source=. --remote=origin --push
Push to GitHub
git push -u origin main
Push an existing repository from the command line
git remote add origin git@github.com:miftah-ahmad-choiri/how-to-setup-github.git
git branch -M main
git push -u origin main
git init
git branch -M main
git status
git add .
git commit -m "ïnitial commit"
git remote add origin https://github.ibm.com/Miftah-Choiri/Miftah-Choiri.github.ibm.com.git
git remote set-url origin git@github.ibm.com:Miftah-Choiri/Miftah-Choiri.github.ibm.com.git
git remote -v
git push -u origin main
🔄 4. Pull Existing Repository
Pull existing repository to local
git remote add origin git@github.com:miftah-ahmad-choiri/how-to-setup-github.git
git pull origin main
# or
git pull git@github.com:miftah-ahmad-choiri/how-to-setup-github.git
git remote -v
git remote set-url origin git@github.com:miftah-ahmad-choiri/miftah-ahmad-choiri.github.io.git
git pull origin master
Pull Rebase
git pull origin develop --rebase
git add .
git commit -m 'add'
git push -u origin develop
🗂️ 5. Branching and Merging
Create and Switch to a New Branch
git checkout -b edit-readme
Push the Branch to GitHub
git push -u origin edit-readme
Merge Changes into Main Branch
git checkout main
git merge edit-readme
git push origin main
Move repo directory to new directory
cp -r how-to-setup-github/ repository/
rm -rf how-to-setup-github/
Remove and Reconnect to remote repository
git remote remove origin
git remote -r
git remote add origin git@github.com:miftah-ahmad-choiri/how-to-setup-github.git
git remote -r
Delete branch & remote branch
git branch -d edit-readme
git branch -D edit-readme
git push origin --delete edit-readme
Verify branch
git branch
git branch -r
Safely Delete .git directory
# remove .git file from repo directory
cd how-to-setup-github
rm -rf .git
cd ..
rm -rf how-to-setup-github
⚙️ 6. Using GitHub CLI (Optional)
Verify GitHub CLI Installation
gh --version
Authenticate with GitHub
gh auth login
Follow the prompts to authenticate via browser.
Create Repository Using GitHub CLI
gh repo create how-to-setup-github --public --source=. --remote=origin --push
Open Repository in Browser
gh repo view --web
📝 7. Troubleshooting Common Issues
-
Repository Not Found:
ERROR: Repository not found.
Fix: Verify repository URL and access permissions.
-
Remote Already Exists:
error: remote origin already exists.
Fix: Remove existing remote and add again:
git remote remove origin git remote add origin git@github.com:USERNAME/REPO.git
💡 8. Helpful Commands
- List branches:
git branch -a
- Check remote repositories:
git remote -v
- View repository list:
gh repo list
✅ Conclusion
This guide covers the end-to-end process of setting up GitHub on your PC, configuring Git, managing SSH keys, creating repositories, and working with branches. For more details, refer to GitHub Docs.
Author: Miftah Ahmad Choiri
Last Updated: 2025-02-01