A simple interactive Bash script that completely cleans and configures Git + GitHub for new systems. Ideal for fresh Linux installs or helping friends set up GitHub the right way — with browser login and test push included!
✅ Cleans old Git configs and credentials
✅ Prompts for GitHub username and email
✅ Auto-detects installed web browsers
✅ Uses GitHub CLI for secure login via browser
✅ Optionally creates and pushes a test repo
✅ Beginner-friendly and safe to run multiple times
Tool | Version or Status |
---|---|
Bash shell | Installed (default in Linux) |
Git | Installed (sudo apt install git ) |
GitHub CLI | Auto-installed by script if not found |
Web browser | At least one installed (e.g., Firefox, Chrome, Brave) |
Clone this repository:
git clone https://github.com/YOUR_USERNAME/github-setup.git
cd github-setup
chmod +x git-github-setup.sh
Simply run the script:
./git-github-setup.sh
- Backs up old
.gitconfig
file if it exists - Removes old Git user/email configs
- Deletes GitHub CLI auth data and credentials
- Prompts you to enter your GitHub username
- Prompts for your GitHub email
- Sets your global Git config (
git config --global
) - You can verify later with:
git config --global user.name
git config --global user.email
-
Auto-detects installed browsers:
- Firefox
- Chrome / Chromium
- Brave
- Edge
- Vivaldi
-
Prompts you to select which browser to use for login
- Authenticates securely with GitHub using the selected browser via GitHub CLI (
gh auth login
) - Logs you in with device flow (OAuth-based)
-
Asks if you want to create a test repo
-
If yes:
- Initializes a local Git repo
- Creates
README.md
- Pushes to new GitHub repo (private)
- Verifies everything works!
After running the script:
- ✅ Git is configured correctly
- ✅ You’re logged in to GitHub securely
- ✅ (Optional) You have a working test repo on GitHub
$ ./git-github-setup.sh
🧹 Cleaning up old Git and GitHub configuration...
🧑 Enter your GitHub username: md8-habibullah
📧 Enter your GitHub email: you@example.com
🌐 Detecting installed browsers...
💻 Available browsers:
1. firefox
2. brave-browser
📦 Select browser number to use for GitHub login: 2
🔐 Logging into GitHub...
✅ GitHub successfully authenticated!
📁 Do you want to create and push a test repo to GitHub? (y/n): y
🚀 Test repository pushed to GitHub!
This project is licensed under the MIT License.
MIT License © 2025 YOUR_NAME
Permission is hereby granted, free of charge, to any person obtaining a copy...
Q: Can I run this multiple times? A: Yes! It automatically cleans and resets everything before setup.
Q: Is SSH supported? A: Not yet — but future versions can add SSH key generation + GitHub upload.
Q: What happens to my old config?
A: It's backed up as .gitconfig.backup.TIMESTAMP
.
Pull requests welcome! If you have ideas (like adding SSH support, GUI version, .deb
installer), feel free to contribute.
Made by @md8-habibullah
Project: github-setup