image

From Local to Remote

A step-by-step tutorial on 2 ways to copy a file from your local computer to an empty GitHub remote repository, either via Command Line or directly in GitHub.

Racquel Tung
Getting Set Up!
Before you start prepping a file to push:

Create a remote repository on GitHub with same name as folder on your local directory. For this example, my repository's name will be “irish-twins”, for my 4 and 5 year olds. As you can see in my local folder, I have a new file ready, named hello.txt. Within it, I added some sample text.

On GitHub: code menu showing setup page

On my local: explorer showing hello.txt

Sample text: contents of hello.txt shown

Using Command Line
In Command Line
  1. Initialize your local repository
  2. terminal showing git init entry
  3. Add your file to the initialized repository that will be pushed to the remote repository
  4. terminal showing git add hello.txt entry
  5. Create an instance of this version of file that you plan to upload to the remote repository. Add a comment of what the change is. Keep the comment in the quotes succinct.
  6. terminal showing git commit -m entry
  7. Add the remote-repository’s location as your new origin of the incoming file.
  8. terminal showing git remote add origin entry
  9. Sanity check: I like to check double check that the destination is correct, so I use:
  10. terminal showing git remote -v entry
  11. And now, the push.
  12. terminal showing git push -u origin master entry

As this is the first push of a new file to an empty repository, the file is pushed to the master branch.

Let's check out GitHub
  1. Open GitHub
  2. Go to remote repository
  3. Under Code menu, you’ll see the new file present.
  4. code menu with hello.txt present
  5. Click on file name to open it, check that your file contents made it.
  6. opened file
Using GitHub
In GitHub
  1. Under Code menu, click “uploading an existing file” hyperlink
  2. code menu showing setup page
  3. Add the file you wish to add by dragging it to the space provided or using the explorer window to select your file.
  4. code menu showing methods to add file
  5. Once added, the filename will appear just above the “Commit changes box”.
    In the “Commit changes” box, leave a comment about the changes. Keep your comment succinct.
  6. As this is an empty repository, we can keep “Commit directly to the master branch” selected.
    Hit the green “Commit changes” button.
  7. code menu showing added file with comment
  8. Going back to the Code menu, you will see your new file added to the master branch.
  9. code menu with hello.txt present
  10. Click on file name to open it, check that your file contents made it.
  11. opened file

Though using GitHub for all actions is more visual, I hope that the Command Line method proves to be an easy approach as well!

About author
placeholder image
Racquel Tung

Racquel is a full-time working mom to two fierce little girls. She, her husband, the kiddos, and shiba inu reside in New Jersey.

Racquel is a forever a student; obtaining degrees and certificates to support her pharmaceutical career. Her latest venture, however, is one that serves her personal interest: coding. She looks forward to the challenge set forth by Moms Can & Co to be fundamentally ready as a Junior Web Developer.

Learn Digital Skills

Find out when the next cohort begins!

The most comprehensive program to up your game in the remote career world.

Learn More
Back