Github is a very great tool if you ask me or the experienced developers. It gives you the power to share code with the world. In the world of programming, two things are very important:

  1. The prowess to make graspable code and,
  2. The ability to copy and paste.

Copying and pasting are not that simple as shown in memes and/or talked with a bit touch of fun. It is done with understanding. You can’t just copy and paste anything in your code if you have concern for cleaner, faster and organized code.

Github is one of the hundreds of tools from which you can basic applications. It is mainly for web developers but the possibilities are illimitable.

Let me come to what I am here for. There are many important Github commands for me. For the full command list, you can visit Github.

But, the most useful and common I’ve messed up with are:

 

To clone a repository

git clone repository-link-here.git

Usage: This command clones the git repository you are trying to achieve. It is simple as that.

 

Adding credentials to your PC

git --config global user.name 'Github-username'

Usage: This command adds one of your Github credentials, ie your username.

Meaning: It goes to configurations, “–config” and adds the user.name “globally” (global)

The username is unique to everyone, in my case, it is ‘gurpreetreact’.

git --config global user.email 'Github-email'

Usage: This command adds one of your second of your Github credentials, ie your Github associated email.

Meaning: It goes to configurations, “–config” and adds the user.email “globally” (global)

The email is also unique to everyone.

 

Initialize or Reinitialize your remote repo

git init

Usage: The 1st command you run when you’ve to commit your changes to your newest created repository. We can also call it the root command.

Meaning: init means, for obvious reasons, initialization

Dictionary meaning of initialization: set to the value or put in the condition appropriate to the start of an operation.”

 

Switching Branches of your repository

git branch -a

Usage: You can use this command whenever you want to know all the branches.

Meaning: -a represents ‘all’. This command shows you all the branches you have in the current repository

git branch new-Github-branch-name

Usage: This command creates a new branch name to the current repo you are in.

Remember: It does not switch to the new-Github-branch-name. It just creates it.

Meaning: branch tells Github that the functionality is regarding branches and it has to create a new one.

git checkout -b 'new-branch-name' (no spaces and without quotes)

Usage: This command creates a new branch name to the current repo you are in.

Remember: It does not switch to the new-Github-branch-name. It just creates it.

Meaning: branch tells Github that the functionality is regarding branches and it has to create a new one.

 

Changes regarding your repository

git status

Meaning: This command prints the changes if they exist. And if there are none, it’ll print, “nothing to commit, working tree clean”.

git add .

Usage: It is the 2nd command you use.

Meaning: “.” symbolizes ALL. It adds all the newly made changes to the staging area, waiting for the commitment.

git commit -m 'some message here'(with quotes)

Usage: It is the 3rd command you use. After you have added, this command commits your changes to the repo. Now, your changes are ready to be made available to your repo with a selected branch. It still won’t show changes in your repo.

Meaning: “commit,” tells Github to commit the “add” ed changes. -m adds the message that is written after it.

git push --set-upstream origin branch-name

Usage: If you’ve created a new branch using “git branch” or “git checkout”, then you’ll use it.

Meaning: This first set a new branch on the Github server and then pushes the code.

git push origin branch-name

Usage: You use it if you have got an existing branch in your repo.

Meaning: This is the last command and it pushes your committed code to your repository.

 

To pull some code

git pull origin branch-name

Usage: Before committing to the old code on your Github repo, a good practice is to first pull what you’ve up there already. And then compare the online changes to your newly created remote changes.

This avoids merge conflicts and lets you know if the code is good to go online or not

 

Repository URL configuration

git remote add origin Github-repo-name.git

Usage: Mainly, for the first time using this command you add some URL, remotely. This will be the URL for which Github will acknowledge your changes, commitments and pushes.

Meaning: remote means ‘local’, add means ‘to add’, origin means to set ‘origin-path’.

git remote set-url origin Github-repo-name.git

Usage: If, in any case, you wish to change the remote URL, you can set it again using the ‘set-url’ parameter.

Meaning: remote means ‘local’, add means ‘to add’, origin means to set ‘origin-path’.

git remote -v

Usage: If you want to acknowledge what are the fetch and push URLs, you can do so with this command.

 

Summary

That’s it Githubbers, these are all the commands you’re gonna need to set up and manage Github Repos decently.

I hope this helped and I am looking forward to helping you more in your future coding endeavours.

Have a great day, stay safe, live a healthy life and don’t forget to enjoy this moment.

Why futz, bro?

 

Feel free to jot down in the comments about what you feel, think about this blog and what references would you need for the future.

LEAVE A REPLY

Please enter your comment!
Please enter your name here