DEV Community

Heidi Fryzell
Heidi Fryzell

Posted on

Using GitHub on Multiple Computers - Day 2.0

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 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 (WSL). In Powershell, opened as an administrator, I ran:

wsl --install
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Install git

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

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode

"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

Then install git:

sudo apt-get install git
Enter fullscreen mode Exit fullscreen mode

confirm success:

git --version
Enter fullscreen mode Exit fullscreen mode

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"
Enter fullscreen mode Exit fullscreen mode
$ git config --global user.email "heidi@test.com"
Enter fullscreen mode Exit fullscreen mode

Clone GitHub Repo to PC

Clone the existing repo to PC:

git clone https://github.com/heidi37/dev-playground.git
Enter fullscreen mode Exit fullscreen mode

Commit/Push/Switch Computers/Pull

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

git push
Enter fullscreen mode Exit fullscreen mode

You will be prompted for a username and password when you do this. You need to use a GitHub personal access token as your password.

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

Github repo screenshot showing commits made on PC

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

git pull
Enter fullscreen mode Exit fullscreen mode

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

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

Not This: Do Not Run Ubuntu

Windows Menu showing where to run Ubuntu app

Resources

Colt Steele video snippet about WSL
Atlassian - Install Git

Top comments (1)

Collapse
 
thorondormanwe profile image
Carlos Rangel

I had to use "git pull origin main" in order to retrieve my code from another computer :). Thanks for the article