Setting up Git on Windows Subsystem for Linux

I was using Git for windows, but this started causing issues with Powershell after i updated it, so i started using WSL instead. This caused a few more complications as i needed to start from scratch again. To start with we need to install git in the terminal. By default, windows uses ubuntu, but i have changed my OS to Centos as i am more familiar with RedHat based OSes.

yum install git 

In order to start uploading your projects to git, i manually created the repo on my git pages. I then created a deploy key per project to ensure i was able to securely communicate with GitHub.

ssh-keygen -t ed25519 -C "your email address" -f ~/.ssh/project_name

Once the keyfile has been generated (i chose not to have a passphrase), copy the contents of the public key (~/.ssh/project_name.pub) into your deploy keys section under the settings of your project on GitHub. Once the key has been installed successsfully, test that you can access your project.

ssh -T git@github.com -i ~/.ssh/project_name
Hi username/project_name! You've successfully authenticated, but GitHub does not provide shell access.

This shows that you are able to connect to your project on GitHub

# cd into your project directory
cd project_name/

# This command initialises your directory and creates a .git folder containg your config file
git init

# This updates your config file with your username
git remote add origin git@repo2.github.com:username/project_name.git

# This adds all files and folders to your tree
git add .

# Once your files, you should see that they have been added with a create mode and permissions
git commit -m "Initial Upload"

# Once all files are added you can run the following command
git push -u origin master

Notes

git rm -r --cached *

or if that doesn’t work, start again

rm -rf .git/
git init
...