GitHub 101: Uploading Files to a New Repository via Command Line

GitHub 101: Uploading Files to a New Repository via Command Line


2 min read

So at this point I assume you should know How to create a Repository, If you don't do checkout my previous article here.

Let's dive in and add files via the Command Line.

  1. Follow the steps 1, 2 and 3 from my previous article!

  2. Once done, You should see a screen like this. image.png

  3. Assuming you have a folder created in your local machine, Open the terminal and redirect to the project directory. (I have three files with boilerplate code) image.png

  4. Run the following command to Initialize the repository.

    git init image.png

  5. Now you have to let your machine know which remote repository you're planning to work on. To do that copy the git remote add origin <url> line from the 3rd step and execute it. image.png

  6. To add all files run git add . or you can add only a specific file by executing git add index.html The former will add files to the changing area and the later will add only the index.html file.

  7. After running the commands, If you want to check the status of your working directory execute git status image.png It will give you an overview of the changes that are tracked and has been added to the stage.

  8. Now, to create a commit execute git commit -m"<Desc. of your commit>"

  9. Finally push your changes by executing git push origin <branch name> image.png

  10. You should now see your files in the repository! image.png

Feel free to drop your suggestions in the comments and if you find it useful give me a like and share it with someone who might benefit from it.

Reach out to me on my Instagram If you have any queries or just want to have a conversation! See you on the flip side.