DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 963,673 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Add Version Control and Remote Access to a Plain Repo
Jackson Reeves
Jackson Reeves

Posted on

Add Version Control and Remote Access to a Plain Repo

Here's a super simple tutorial for beginners. So simple that it's essentially exactly what GitHub posts on its site to help people out with this exact situation. I merely added three lines of commands to fill in some unfortunate gaps.

Scenario

You have a repo on your computer with all the code you need for your project. It works great. The only downside? It doesn't have any version control. As in, it ain't a Git repo. As a result, it also isn't shared anywhere (e.g., GitHub). You want to fix this, but how?

If you log in to your GitHub account and create a new repo, it gives you three different options for building out your shiny new remote repo. The second option makes the most sense for this scenario: "…or push an existing repository from the command line." You do have an existing repo, and you do love the command line. However, if you merely cd into your existing repo and run the three commands that GitHub provides, you'll quickly see that you actually need do a few more steps to accomplish your goal.

Solution

Here's my full guide to Git-ifying an existing repo and migrating it to GitHub.

After logging in to your GitHub account and creating a new repo, go back to your Terminal app and cd into your local repo. Then:

  1. git init
  2. git remote add origin https://github.com/<YOURUSERNAME>/<YOURREPONAME>.git
  3. git branch -M main
  4. git add .
  5. git commit -m "Add initial files from local"
  6. git push -u origin main

Note that steps 2, 3, and 5 are verbatim from GitHub's recommendations. While my three "missing steps" may seem painfully obvious to any experienced developer, I wanted to highlight them for the more junior members among us.

Top comments (0)

🌚 Browsing with dark mode makes you a better developer.

It's a scientific fact.