How to upload files in Github/ Gitlab with CLI

Nipun Parekh
2 min readJun 18, 2020
  1. First Install Git Bash in your system. you can install from this link Git Bash

First, move to that directory from which you have to upload files.

example: I have to upload my upload.txt from Example/nipun folder at desktop so I will first go at path and directory.

Now I will execute commands.

$git init //for git initialize

$git add . //this will add our files in .git folder

$git commit -m “Nipun” // short message

In this short message is Add files via upload

$git remote add origin <Your repository URL>

$git push origin master

If you are facing error in upload files then execute this command

$git push -f origin master //-f for forcefully updating

👆 If you will do this then all the files will be deleted and then only single will upload

All the commands are the same for upload files in GitLab just change your URL example : 👇👇

at this:

$git remote add origin <Your repository URL> //gitlab / github URL

Let’s check :

All the commands that I have executed to upload a file on my GitHub repo
Successfully uploaded on my Github Repo.

🎊🎉We have successfully uploaded the file in GitHub 🎊🎉

If you have any query fill free to ask at nipun.parekh7@gmail.com

--

--