GitHub Commands

Rida Jamil
4 min readApr 4, 2021

When you enter the programming world, one of the most important things one must learn is how to keep a backup and track of files. It could be a hassle if you could not get back to the older versions of your program or lose your code because of a file/system crash. I’ve been there and the game becomes frustrating when you could not find the backup.

To help in tracking changes and files, Github offers great help. While learning full-stack development at Jadu Full Stack Fellowship Program, along with many other things, I also learned how to keep changes and backups, or how to keep files accessible to my peers without bugging them with unlimited emails, using GitHub.

Before going to the commands, you need to understand that Git and Github are two different things but linked together. While git is an open-source present in your local system, Github serves as a cloud-hosting platform for collaborating on git repositories. We use git to send our files to the host i.e. Github.

You can add and update changes using easy peasy buttons available on the Github site. But as a good practice programmer, one should do it properly, using commands. Though there’s a large number of commands available for different actions, I’ve gathered here a list of commands that are used commonly.

1. ~ Initiating Git in Local Directory ~

When you’re starting to make a repository (repository is like a folder), you need to create an empty folder of git within the folder your files are present. The folder is created using the git init command in the terminal of the main folder as shown below.

#Git-Init.GIF

2. ~ Adding files in the folder ~

After creating the folder, you need to add the files or changes to the folder. for this, we can use git add . → To add all the files to the folder. With git add, all the files are staged in the directory to be committed.

#Git-Add.GIF

3. ~ Committing Changes ~

By commit, it means to add the snapshots of the entire repository that has been added using the git add branch. It records all the file snapshots permanently. To commit changes, we use the command: git commit -m “your message”.

Within the inverted commas, you need to put any message that would give you any information about the commit such as first commit, or updated pages, etc.

** You can also check the status of the folder after each step using git status.

#Git-Commit.GIF

4. ~ Link to Github ~

If you’re a first-time user, you’d need to log in to your GitHub profile from the local repository. You can log in using:

git config — global user.email “youremail@gmail.com”

git config — global user.name “My User Name”

Now, you’re required to add the link to the cloud folder where you want to add your files. To add the link, use:

git remote add origin <File.path>

Here, the path will be the link to your GitHub folder.

5. ~ Pushing the files/changes in the cloud i.e. GITHUB! ~

Finally, you need to push all the files or the changes that you committed previously in git, to the cloud folder Github.

git push origin main

Main (or master) is the branch present in GitHub since you made the repository.

#Git - Remote & Push.GIF

Taa Daa — We have successfully uploaded all the files on the cloud. Now it can be accessed from anywhere!

But wait, what if I add something in my file on the local repository? How to update my cloud folder? In that case, you have to do steps 2, 3 & 5 i.e. add, commit & push respectively.

#GIt-Update.GIF

Final Words

As a programmer, you must practice git and make sure to upload all your projects on Github. I used to think of GitHub as all the other cloud services. But, while working in the professional field, I realized how important thing it is to learn.

I’d share about the GitHub collaboration more in my other blog. Meanwhile, I can share some of the cheatsheets that helped me in working on GitHub as well as in writing this blog.

--

--

Rida Jamil
Rida Jamil

Written by Rida Jamil

Rida Jamil is a Web developer and learning to become a Full Stack Developer. Tech-writing is one of the many skills that make her stand out from her colleagues!