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
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.
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
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 as your password.
And here is my first commit/push from my PC:
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. 🤣
❗ 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
Not This: Do Not Run Ubuntu
Resources
Colt Steele video snippet about WSL
Atlassian - Install Git
Top comments (1)
I had to use "git pull origin main" in order to retrieve my code from another computer :). Thanks for the article