No Linux No Life – How to Upload Your Source Code to GitHub with Terminal

I must confess that I have a strong dislike for Graphical User Interfaces (GUI), which is one of the reasons why I lean towards Linux over Windows. I simply don’t appreciate the concept of handling computer processes through GUI, which can be confusing for users and tends to undergo frequent UI changes. What I truly appreciate about command-line interfaces is the steadfast consistency they offer, unlike GUI, and the constant demand for command-line skills within the tech industry.

And this time around, I had to upload my PHP files to GitHub, and I did it solely on the terminal. Here are the steps.

Push:

  • Create a new git repository.
  • Create a directory where the file you want to upload to GitHub is stored and change the directory to it.
  • In the directory, execute this command:
git init
  • Copy the HTTPS link to the GitHub repository.
  • In the directory, execute these commands:
git remote add origin “https://github.com/user_name/repository_name.git”
git remote -v
git add .
git commit -m “comment”
git push origin master

Clone:

And here’s how you can clone (download/fetch) source codes from your GitHub repository.

git clone https://github.com/user_name/repository_name.git

This command shows you your currently selected branch.

git branch

And here’s how you can change the branch. Wow… simply wow. “checkout” is something I’ve always been familiar with Eclipse IDE.

git checkout main

This command deletes a local branch.

git branch -d master

Leave a Reply