What is GitHub and how do I use it?

When Learning how to program there is a good chance that you have heard of the word GitHub thrown around. Perhaps you have stumbled across a GitHub repository when doing your research on software development. GitHub could still seem very confusing if you have never used it before. Is it a cloud storage site? A social networking site for programmers? A code-sharing site? As it turns out, the answer to these is yes, and more.
What is GitHub?
GitHub is an online software development platform used for storing, tracking, and collaborating on software projects. It enables developers to upload their own code files and to collaborate with fellow developers on open-source projects. GitHub also serves as a social networking site in which developers can openly network, collaborate, and pitch their work.(GitHub.com) Since its founding in 2008 GitHub has Grown to support 83 + million Developers and holds a whopping 200 + Million Repositories. Besides helping developers and teams work and share code, GitHub is also a place where developers can showcase their work, build a portfolio or personal brand, this feature allows GitHub to become a social network for web developers around the globe. In order to fully understand how GitHub works, it is important to understand the technology that GitHub is based on.
What is Git?
Git is an open-source version control software used for tracking any file revisions. Git itself can be used with any file type but it is generally used for tracking and storing code files. Git is the most widely used version control software and GitHub uses this technology to offer its services. You’ve likely worked with some form of version control before. For example, Google Docs (as well as other Google Workspace tools) has a “Version History” tool where you can view changes to the document at different points in time. When a developer wants to make a change to a codebase, they download their own copy of the source code from its central storage location (called a repository, or “repo” for short) to their local system, make modifications safely to their own copy, then merge their revised copy back with the source files in the repository along with comments explaining the changes. Git tracks all of these modifications and stores previous versions as backups.
What is GitHub Used for ?
GitHub allows software developers and engineers to create remote, public-facing repositories on the cloud for free. Once you’ve set up a repository on GitHub, you can copy it to your device, add and change files locally, then “push” your changes back to the repository where your changes are displayed to the public. So what are the benefits of using GitHub ?
Enhanced Collaboration
Easy File Management
Social Networking
How to Get Started Using GitHub?
Before you get started please note that you must be comfortable using the command line as git uses this for its interface.
Install the latest version of git on your device. There are various ways to do this, so follow the recommendations on the Git website. The Git software is free
once you have installed git head over to www.github.com and create an account with your email addresses.
Once your GitHub account is set up, you’ll be taken to your dashboard. To start your first repository, click Create repository on the left side.

4. On the Create a new repository screen, enter your repository name and an optional description (you can change both later).
5.On the same screen, add a README file (a text file that describes your project, and a best practice in development), a .gitignore (which removes irrelevant files like .DS_Store), and a license for your project.

6. Click Create repository. You’ll be taken to your main repository page, which lists your files.
7. You’ll now create a local copy of your GitHub repository (or in GitHub terms, “clone” your repository) where you’ll edit your files and push your changes. On your main repository page, click the green Code button, then copy the HTTPS URL of your repository.

8. Open your terminal and navigate to the directory you want to place your repository copy.
9. In the terminal, enter git clone. After, this paste in the repository URL that you previously copied. Your command should look like this:

10. Press Enter to clone the repository. You’ll see a new file added to your local filesystem with your repository’s name. If you open this file, you’ll see it contains the files in your GitHub repository. These are copied versions of your repository’s files that you can edit and then push back to your repository.
11. Let’s end by creating a new file in your cloned repository, then pushing it to GitHub. In your local clone, create a new text file called hello.txt. In it, paste the text Hello, world! and save the file.
12. In the terminal, navigate to inside your cloned repository.
13. In the terminal, type git add. and press Enter. This prepares all files in your cloned repository to be pushed.
14. In the terminal, type git commit -m “added hello.txt” and press Enter. This commits your changes to the change log. The text in quotes is a comment briefly describing the purpose of the commit.
15. Type git push origin main in the terminal and press Enter.
16. Back in your GitHub repository, you’ll see your new file added.

Conclusion
As you learn the in's and out's of GitHub, you will begin to really appreciate git and the amazing service called GitHub. Creating a repository for every project that you work on will ensure that even if you spill your Piña colada on your laptop on the beach, you will always have a copy of your code that you are working on. Be sure to commit your code to the repository after any major change. Happy Coding !
source: www.hubspot.com


Comments