Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
December 10, 2020 06:15 am GMT

How to put your project into a GitHub repo

You've created a new project, and it's currently saved on your computer. Great! Hopefully, you haven't gotten too far into it yet because it's always a smart move to have version control of your code.

By version control, I mean, keeping track of any and every change that was done in your code, just in case it accidentally breaks along the way. In the event that it does happen, you can revert your code to how it was before you broke it. (Don't feel bad - it happens.) Here's an article from Atlassian that explains it better than I did and how it can save your butt one day.

Before I get started, I'm going to assume you have the following:

  • A GitHub account that's properly synced with your computer

  • Basic working knowledge of the command line

  • VSCode (If you're not using this, I highly recommend it.)

(Side note: This is just one of the ways to save a project into a new GitHub repo, and it's the way that I do it.)

Okay, let's do this!

  1. When you're logged into your GH account, you should see a '+' on the top right of your screen. Click that icon, and select 'New repository.'

  2. Fill out the 'Repository name' field. (Btw, repository/repo is just another way of saying a project folder--a folder where all the project's files/imgs/documentation/whatever-the-project-needs lives.) Usually, the repository name is all lowercase, and if the name has multiple words in it, you would name it something like where-are-my-keys.

  3. This is marked optional, but you should also fill out the 'Description' field. You can write 1-2 sentences here about the purpose of your project/what it does.

  4. Choose whether this is a public or private repo.

  5. Skip the part about initializing the repo with a README, .gitignore, or license. We'll get to adding those soon.

  6. Create repository! But you're not quite done yet. It should've brought you to a 'Quick setup' page. We'll mostly be looking at the 'or create a new repository on the command line' section.

  7. In VSCode, with your project open, open the integrated terminal. Make sure the terminal is accessing your root/main directory for your project. If it's not in the right directory, you'll need to cd (change directory) into the correct one.

  8. Once that's all good to go, type (or copy-pasta) one command at a time in the command line, pressing the 'Enter' key after each one.

  • git init - Adds a .git folder in your project directory.

  • touch README.md - Creates a README file.

  • git add . - Saves all of the files and changes you've made in your project and "packages it" all together to get it ready for GitHub.

  • git commit -m "first commit" - This "labels" the "packaged" files from above with the message you give it. This has the message, "first commit," which is a pretty standard message when first committing. Any time after this, it's extremely important to write short, meaningful commit messages about what changes you made in your code, and that you're doing it frequently.

  • git branch -M main - Renames your current branch (which should be called 'master' for now) to 'main'.

  • git remote add origin [email protected]:your-github-name/where-are-my-keys.git - Don't copy this exact command, but copy the one that looks like it in the 'Quick setup' page.

  • git push -u origin main - The moment we've been waiting for! This pushes all your project files into the new GH repo.

  • There's one last thing to do, and that's to make sure everything went through as expected. Reload the 'Quick setup' page. It should bring you to your new repo. Do a quick scan of your files, and you should also see your first commit message.

If all went well and everything is where it should be... HOORAY! I'm giving you the biggest virtual high-five right now.

If not, don't panic. Comment below, and let's figure it out.


Original Link: https://dev.to/ennalezah/how-to-move-your-project-into-a-github-repo-3kic

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To