This tutorial assumes you have already ran the following commands, if not then you can run them now but it might be easier to just make a repository and clone it.

Initialising the current directory using git

1
git init

Adding current files to a commit

1
git add .

Creating the commit

1
git commit -m "Your commit message"

Now that you have created a commit, you can simply run the following command:

1
git remote add origin YOUR_REPO

For example:

1
git remote add origin https://github.com/editid0/blog

If your repository is a private one, like mine, then you will need to be signed in.

Now push your changes:

1
git push -u -f origin main

Now if you go to your repository on GitHub, you should see your files. You have successfully added your existing files to a new GitHub repository.