Skip to content
Coding Fanatic
  • Android Development
  • News and Reviews
  • Road2Pro
  • Tutorials
  • Services
  • About

How to Push a Local Repo to Github, 39/100…

  • August 5, 2019August 5, 2019
  • by Richard Clarke

Pushing changes to a cloned repository is straightforward, but sometimes you want to create a repo on Github after you start your project.

NOTE: This tutorial assumes you have Git installed, know how to create a git commit, and have experience creating repos on Github.

Most developers who are new to Git only know how to work on projects **after** cloning from Github. But what if you want to push a local repo to Github?

Fear not! I have the written steps below followed by a YouTube video at the bottom of the page.

What you’ll need open:

  • A terminal window
  • TIP: You can use Visual Studio Code for its terminal as well. I leave this up to you.
  • Android Studio, or whichever IDE you’re using to generate a new project.
  • Your browser of choice open to your dashboard at https://github.com/

Step 1: Create a new project locally

  •  At the Android Studio intro screen, create a new project.
  • TIP: Use camelback casing and make it one word. This will be the name of our repo on Github.
  •  Save it to a directory of your choosing (ex: localRepo)

Step 2: Create a new Github repo for your project

  •  Navigate to your Github dashboard and create a new repository
  • IMPORTANT: Make sure the new repo name matches that of your project.
  •  Click the green Clone or download button and copy the URL of your newly created Github repo

Step 3: Use git in the terminal to push your project to Github

  • TIP: In Visual Studio Code open the terminal using Ctrl + `
  • Change to the parent directory of your project using the cd command
  • Ex: If your projejct directory is in *user/workspace, use the command cd user/
  • Enter the commands below to complete this step.
  • TIP: Do not include parentheses for your URL. Just paste it as is.
  • git init yourRepoName
  • cd yourRepoName
  • git remote add origin (URL copied from Github)
  • git pull origin master
  • git add –all
  • git commit
  • Enter your custom commit message and exit the editor
  • git push –set-upstream origin master

Step 4: Refresh the page in Chrome and marvel at your works.

Hopefully this helped! If you want to see this in action, watch the YouTube video below.

-CF

Related

Jumped the Wall After All, 38/100 Days of Code
How to Create a Custom ActionBar, 40/100 Days of Code
Richard Clarke
Richard is currently a developer using Java and Android Studio to build custom applications for Android. Richard tutored in mathematics at Montgomery College, and worked in Information Technology before entering the Software Development industry as a Quality Engineer.
100daysofcode Android Studio AndroidDev

Related articles

Your New Favorite Stopwatch App!…
Two for Two BABY! 7…
…But the App is for…
Play Store Blues – 5…
Top 4 Tips for Android…
No Dice – 3 of…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • GitHub
  • YouTube
  • X
  • Instagram
  • LinkedIn
My Tweets

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • X
  • GitHub
  • LinkedIn
  • YouTube

Archives

Theme by Colorlib Powered by WordPress