GitHub is a web service that helps developers store, track and control changes to their code.
Ensure to have git installed and setup on your machine. You can download git here.
Visit Github and create an account or sign in if you already have one and then create a new repository called stacky.
Head back to our project, open up the terminal and initialize an empty git repository;
$ git init
Add a .gitignore file at the root of our project. A .gitignore file specifies which files and folders should be ignored in a given source code. This means this files and folder will not be pushed and tracked by git.
/node_modules /dist .env yarn-error.log
Notice we added our .env file to be ignored because the .env file usually contains sensitive or localized information. In the case of sensitive information, like API keys, authentication keys and so on, we won't want these sitting in version control where they can be publicly accessed.
But then how do any user who pulls our projects knows what environment variables needs to be set. Simple, let's add a .env.example file and as the name implies this is just an example file which users can then use to create their .env file. So let's add this file to the root of our project.
PORT= DB_HOST= DB_USERNAME= DB_PASSWORD= DB_DATABASE=
Next, we need to stage and commit our changes;
$ git add . $ git commit -m"First commit"
Back to the Github screen on the browser, scroll down to the "... or push an existing repository from the command line" and copy the commands into your terminal.
Head to your GitHub repo and you should see your codes in the main branch.
Heads up: If you have a previous version of git installed on your system, your default branch might be master.