DEV Community

Monish B
Monish B

Posted on

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

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

  1. 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>
Enter fullscreen mode Exit fullscreen mode

line from the 3rd step and execute it.
image.png

  1. To add all files run
git add .
Enter fullscreen mode Exit fullscreen mode

or you can add only a specific file by executing

git add <filename>
Enter fullscreen mode Exit fullscreen mode

The former will add files to the changing area and the later will add only the index.html file.

  1. After running the commands, If you want to check the status of your working directory execute
git status
Enter fullscreen mode Exit fullscreen mode

image.png It will give you an overview of the changes that are tracked and has been added to the stage.

  1. Now, to create a commit execute
git commit -m"<Desc. of your commit>"
Enter fullscreen mode Exit fullscreen mode
  1. Finally push your changes by executing
git push origin <branch name>
Enter fullscreen mode Exit fullscreen mode

image.png

  1. 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 @monish.codes If you have any queries or just want to have a conversation! See you on the flip side.

Top comments (0)