This guide walks you through the initial Git config and setting up your Personal Access Token in a Windows dev environment.
My two assumptions for this are that you have Windows 10/11 and WSL already installed.
The terminal commands used are based off of Ubuntu/Debian based Linux distributions.
Git should come pre-installed on most, if not all of the WSL Linux distributions. To ensure you have the latest version, use the following command in an Ubuntu or Debian based distro:
sudo apt install git
To set up your Git config file, open a WSL command line and set your name with this command (replacing "Your Name" with your preferred username):
git config --global user.name "Your Name"
Set your email with this command (replacing "firstname.lastname@example.org" with the email you prefer):
git config --global user.email "email@example.com"
And finally, add your GitHub username to link it to git (case sensitive!):
git config --global user.username "GitHub username"
Make sure you are inputting
user.username and not
user.name otherwise you will overwrite your name and you will not be correctly synced to your GitHub account.
You can double-check any of your settings by typing
git config --global user.name and so on. To make any changes just type the necessary command again as in the examples above.
GitHub has removed the ability to use a conventional password when working in a remote repository. You are now required to create a personal access token instead.
Follow these docs for step-by-step instructions on creating your personal token.
Once you enter in your token the first time, it can be stored via Git Credential Manager (GCM) so you won't have to authenticate yourself each time.
You can have Git installed in WSL and also in Windows at the same time. Git for Windows includes GCM and is the preferred way to install it.
You can also download the latest installer for Windows to install the GCM standalone version.
Once Git Credential Manager is installed you can set it up for use with WSL. Open your WSL terminal and enter this command:
git config --global credential.helper "/mnt/c/Program\ Files/Git/mingw64/bin/git-credential-manager-core.exe"
If you ever receive the following error message:
/mnt/c/Program\ Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe store: 1:
/mnt/c/Program Files/Git/mingw64/libexec/git-core/git-credential-manager-core.exe: not found
Try using the this command:
git config --global credential.helper store
That wraps up the basics for a Git config on Windows! If you are interested in learning more, check out my Git a Grip series.