Create a GitHub Repo and Back up your Project
First, open up your terminal and move into the root of your project. For example, if your project is in a folder called ‘delicious’ on your Desktop, you would run the following in your terminal:
cd ~/Desktop/delicious
You can also type cd
, a space, and drag and drop the project into the command line. Or you can control click on the project folder and choose the option to open git-bash or a new terminal. Any of these three options will work.
Once you are in the directory (run pwd
to make sure), place your project under version control:
git init
Then add and commit all of your files:
git add -A git commit -m "initial commit"
Great! Now your project is ready. Next, you’ll make a home for it on GitHub.
Log on to GitHub and open your dashboard or list of repositories. Create a new repository by clicking on the green "New" button.
Give your new repository a name, preferably something that makes it easy to see which project this repository is linked to. Keep the name lower case and use dashes instead of spaces. Add a description if you like, leave “Public” checked and don't change any of the other settings. Then click "Create repository".
The next page will give you a few options as to how you would like to get your files up on your shiny new GitHub repository. First, make sure "ssh" is selected under "Quick setup". Then, given that we have already set everything up in the terminal, we will choose the second option to “push an existing repository from the command line.”
Click the clipboard icon to copy the commands. And paste the commands into the terminal or GitBash. Then press the Return key.
Refresh your GitHub page, and… snapadoodle! Your files are all there!!
You now have a backup of your project! And you can share this link with whomever you like (as long as your repository is set to Public) and even collaborate with other developers if you want to.
Throughout the lifetime of your project, remember to keep adding and committing your files as you work on them, and to push up your changes by running git push origin main
(or the branch name you're pushing.)
That’s it! Your code has been “Gitified” just like a pro. Time to celebrate! 🎉