Using GitHub on Multiple Computers - Day 2.0
Tags: github, git
Published: 2022-01-16 14:31:08

I have two computers and I want to work on both of them to simulate working on a team. I want to get used to pulling code not just pushing it.

I already had Git installed on my Mac. This morning I set up my PC to work on my [dev-playground](https://github.com/heidi37/dev-playground) repo. Here are all the steps I took...

##Windows Subsystem for Linux

I want to use Linux Commands in the command-line so I installed the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install) (WSL). In Powershell, opened as an administrator, I ran:
```
wsl --install
```
This installs Ubuntu and sets up an Ubuntu file system in Windows.

I will keep my web projects in the Ubuntu file system directory

```
\\wsl$\Ubuntu\home\heidi
```
I am running my command line from the "Ubuntu App" on Windows but you can also install Windows Terminal for a fancier interface and to run other terminals like Powershell, etc... all from one place.

![Ubuntu App terminal window](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9w0e4q8rqcpi7ppvzqn2.png)

##Install git

I was inspired to install the WSL so that I could install git with just two commands:

```
sudo apt-get update
```
"apt" is a package manager and this command "updates the package lists for upgrades for packages that need upgrading, as well as new packages that have just come to the repositories" ~[askubuntu.com](https://askubuntu.com/questions/222348/what-does-sudo-apt-get-update-do)

Then install git:

```
sudo apt-get install git
```
confirm success:
```
git --version
```

If you get a version number, it worked. 🙌

Configure username and email that will be tagged on your commits:

```
$ git config --global user.name "Heidi Pc"
```
```
$ git config --global user.email "heidi@test.com"
```
##Clone GitHub Repo to PC

Clone the existing repo to PC:

```
git clone https://github.com/heidi37/dev-playground.git
```

##Commit/Push/Switch Computers/Pull

Make a change and commit it from the PC. Push it to GitHub
```
git push
```

You will be prompted for a username and password when you do this. You need to use a GitHub [personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) as your password.

And here is my first commit/push from my PC:

![Github repo screenshot showing commits made on PC](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2kby23k0zb3g1g24ptcr.png)

Do a pull request on the Mac to pull down the new commit.

```
git pull
```

This pulled down all the changes I made from my PC.

I am sure a some point I will get into trouble with not keeping everything pushed and pulled and in sync. When I run into trouble I will write about it on [dev.to](https://dev.to/heidi37). 🤣

❗ **IMPORTANT - NEWBIE ERROR** ❗

In order to run the Ubuntu/Linux command line to communicate with Git, GitHub, etc... You need to run WSL.exe, every time you start your computer. I was getting all these errors because you will see an Ubuntu App in your programs list but you can't run it without first having WSL running.

**Do This: Run WSL.exe**


![Windows Menu showing where to run WSL](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e8rpdhmlvyup8acf2q9y.png)

**Not This: Do Not Run Ubuntu**


![Windows Menu showing where to run Ubuntu app](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2adxtszw2044t2t2slag.png)


###Resources
Colt Steele [video snippet about WSL](https://www.youtube.com/watch?v=ZtqBQ68cfJc&t=1265s)
Atlassian - [Install Git](https://www.atlassian.com/git/tutorials/install-git#linux)