There are a couple ways to set up Git on Windows:
- Recommended Option: Installing Git within a Linux environment using Windows Subsystem for Linux (WSL) and Ubuntu.
- Alternative Option: Installing Git directly on Windows.
Familiarity with Linux is really useful, because a lot of software companies run their code on Linux-based infrastructure. Getting experience with Linux can enhance your development skills and improve your employability.
Familiarity with Git is basically essential. Everybody uses it.
Note that there's a difference between Git (which is a tool used for version control) and GitHub (which is a place you push code to and pull from). It allows version control, and creates a new point in the history of the code every time you make a commit and push. You can walk back through this history and rebuild the code from that point, if you need, or create branches to try out new ideas without breaking the
master
branch.
By enabling WSL, you can run a Linux distribution alongside your Windows system. This is what I do, and what I recommend.
-
Enable WSL:
- Open PowerShell with administrator privileges: Right-click on the Start button and right-click on Windows PowerShell, then select "Run as administrator."
- Run the following command to enable WSL and install the default Ubuntu distribution:
wsl --install
- Restart your computer when prompted.
For detailed instructions, look at Microsoft's official documentation: Install WSL
-
Install Ubuntu and Windows Terminal:
-
Initialize Ubuntu:
- You may be prompted to reboot your PC. Do so if needed.
- Start > Ubuntu on Windows
- Follow any prompts for username and password. A home directory will be created for your user.
-
Update Package Lists:
- In the Ubuntu terminal, run:
sudo apt update
- In the Ubuntu terminal, run:
- Install Git:
- In the Ubuntu terminal, execute:
sudo apt install git
- Verify the installation by checking the Git version:
git --version
- In the Ubuntu terminal, execute:
- Set Up User Information:
- Configure your name:
git config --global user.name "Your Name"
- Configure your email:
git config --global user.email "your.email@example.com"
- Configure your name:
- Create and Navigate to
Repos
Directory:- In your home directory, create a
Repos
folder:mkdir ~/Repos
- Navigate into the
Repos
directory:cd ~/Repos
- In your home directory, create a
- Clone the Repository:
- Enter the credentials you just made when prompted
git clone https://github.com/gooselord-0/project.git
We'll copy over your existing hobby project here, then change into the directory, then add the new files to git, then push it out to GitHub. You may run into issues here if your .flac files are greater than 100MB in size. Let me know if that happens, or ask an LLM, "How do I enable git LFS?"
- Copy Files into the Repository Directory:
- Replace
#username#
and#project-location#
with your Windows username and the project's path:cp -r /mnt/c/Users/#username#/#project-location#/* ~/Repos/project/ // e.g., cp -r /mnt/c/Users/#username#/Documents/Code/HobbyProject ~/Repos/project/
- Replace
If you use whitespaces in your project path (e.g., "/mnt/c/Users/#username#/Hobby Project", the space after "Hobby" and before "Project"), get in the habit of enclosing the path in double quotes. Commands will otherwise fail.
-
Stage All Files:
- Navigate to your project directory:
cd ~/Repos/project
- Stage all changes:
git add .
- Navigate to your project directory:
-
Commit Changes:
- Provide a meaningful commit message describing the changes:
git commit -m "#Describe the changes made#"
- Provide a meaningful commit message describing the changes:
-
Push Changes to Remote Repository:
- Push the committed changes:
git push origin master
- Replace
main
with the appropriate branch name if different.
- Push the committed changes:
If you prefer not to use WSL, you can install Git directly on Windows.
-
Download Git for Windows:
- Visit the official Git website: Git for Windows
- Download the latest version of Git for Windows.
-
Run the Installer:
- Locate the downloaded
.exe
file and double-click to run it. - Follow the installation prompts, selecting default options unless you have specific preferences.
For a detailed walkthrough, refer to this guide: How to Install Git on Windows
- Locate the downloaded
- Set Up User Information:
- Open Git Bash (installed alongside Git).
- Configure your name:
git config --global user.name "Your Name"
- Configure your email:
git config --global user.email "your.email@example.com"
- Create and Navigate to
Repos
Directory:- In Git Bash, create a
Repos
folder in your home directory:mkdir ~/Repos
- Navigate into the
Repos
directory:cd ~/Repos
- In Git Bash, create a
- Clone the Repository:
- Replace
#project-url#
with the actual repository URL:git clone #project-url#
- Replace
- Copy Files into the Repository Directory:
- Use Windows File Explorer to copy ::contentReference[oaicite:0]{index=0}