- Create a new repository in Github by clicking the plus sign in the top right corner of your Github page and clicking “New repository” from the dropdown menu. This will bring you to a new page where you can specify a name for the new repository, write a description, and add additional information and content, like a Read Me.
2. Now that you have a repository go to your terminal and change the current directory to your project.
3. Initialize your directory as a Git repository by running the following code in your terminal. This initializes the repository with main as the default branch.
git init -b main
4. Add the files in new local repository and stage them to be committed by running the following code in your terminal.
git add .
5. Commit the files you just staged by running the following code in your terminal.
git commit -m "Your commit message"
6. In your terminal run the following code. The remote URL is the URL for the Github repository for this project. You can get this link by clicking the “Code” button in your Github repository. This will open a tooltip with your URL.
git remote add origin REMOTE_URL
7. Once you have added your remote origin you can verify it with the following code. This should show two lines, each starting with “origin” and your Github link and ending with fetch and push, respectively.
git remote -v
8. Finally you can push your code to your Github repository with the following code.
git push origin main