Skip to content

A Bash script to automate a clean Git & GitHub setup from scratch. It completely wipes existing Git/GitHub configurations, prompts for your GitHub username and email, detects installed browsers, then securely logs in via the GitHub CLI with your chosen browser. Optionally, it creates a test repository to verify the setup in one seamless run.

License

Notifications You must be signed in to change notification settings

md8-habibullah/github-setup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🚀 GitHub First-Time Setup Script

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!


🧩 Features

✅ 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


🛠️ Requirements

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)

📥 Installation

Clone this repository:

git clone https://github.com/YOUR_USERNAME/github-setup.git
cd github-setup
chmod +x git-github-setup.sh

▶️ Usage

Simply run the script:

./git-github-setup.sh

🧼 What This Script Does (Step-by-Step)

1. 🔄 Clean Existing Configs

  • Backs up old .gitconfig file if it exists
  • Removes old Git user/email configs
  • Deletes GitHub CLI auth data and credentials

2. 🧑 Ask for GitHub Info

  • Prompts you to enter your GitHub username
  • Prompts for your GitHub email

3. ⚙️ Configure Git

  • Sets your global Git config (git config --global)
  • You can verify later with:
git config --global user.name
git config --global user.email

4. 🌐 Browser Detection

  • Auto-detects installed browsers:

    • Firefox
    • Chrome / Chromium
    • Brave
    • Edge
    • Vivaldi
  • Prompts you to select which browser to use for login

5. 🔐 GitHub Login

  • Authenticates securely with GitHub using the selected browser via GitHub CLI (gh auth login)
  • Logs you in with device flow (OAuth-based)

6. 📦 Test Repo (Optional)

  • 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!

📁 Output

After running the script:

  • ✅ Git is configured correctly
  • ✅ You’re logged in to GitHub securely
  • ✅ (Optional) You have a working test repo on GitHub

🧪 Example

$ ./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!

🪪 License

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...

🙋‍♂️ FAQ

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.


🤝 Contributions

Pull requests welcome! If you have ideas (like adding SSH support, GUI version, .deb installer), feel free to contribute.


🌐 Author

Made by @md8-habibullah Project: github-setup


About

A Bash script to automate a clean Git & GitHub setup from scratch. It completely wipes existing Git/GitHub configurations, prompts for your GitHub username and email, detects installed browsers, then securely logs in via the GitHub CLI with your chosen browser. Optionally, it creates a test repository to verify the setup in one seamless run.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages