Writing a Ruby Program: Part III

Joy Evans
3 min readOct 15, 2021
Photo by Joshua Fuller on Unsplash

So a couple of weeks ago, I can up with this fun idea to come up with a "Random Activity Generator" using Ruby. In the last blog, I reviewed selecting random values, case statements, and using require_relative. This week, I'll go over pushing your local repository up into your remote repository in GitHub. So let's get started!

We'll start by creating a new repository on your GitHub account. Click the green button that reads "New" (see image below).

Create a new repository

Next, it'll redirect you to create your new repo. First, we'll give it a name, preferably a name that isn't being used (STEP 1), then decide whether it'll be a public or private repo (STEP 2), and finally click "Create Repository" (STEP 3).

Create a new repository — Step 1 &2
Create a new repository — Step 3

After officially creating your new repo, it'll redirect you to a new page giving you instructions like so:

After creating repository — View 1
After creating repository — View 2

Before we push our existing code into the repo, we're going back to our code to run git status from your command line to check the state of the working directory and staging area. The following error message may appear:

Untracked files:
(use "git add <file>..." to include in what will be committed)
../.DS_Store
./
nothing added to commit but untracked files present (use "git add" to track)

This message means that Git sees multiple untracked files, and it won't include those files until it's told to do so. Just run git add . to add all untracked files in the current directory to the next git commit. Now we can run git status again to confirm that our two files are there. You should see the following message:

On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: activity.rb
new file: greetings.rb
Untracked files:
(use "git add <file>..." to include in what will be committed)
../.DS_Store

Now that the files are there, we going to run the following code:

git commit -m "initial commit"git remote add origin [copied web address]git branch -M main

git push origin master

Now you should see all your files on your remote repo like so:

After pushing into the remote repo.

--

--

Joy Evans

Software Engineer | C# | Angular | Ruby on Rails | Javascript | React