Github for Beginners
Last Moment Tuitions
Blog: a blog about learning Github as well as ways it can help you.
Github for Beginners
Humans have always sought ways to connect and collaborate as a group; throughout time, we have evolved new digital means of connecting, allowing us to collaborate regardless of location. Facebook and Twitter have become indispensable in our daily lives. Another example of software that allows people to connect and interact more efficiently, rapidly, and dynamically is GitHub. In this blog, I’ll explain how GitHub works and how we may use it for a variety of reasons.
How to Start using GitHub:
- GitHub may be used by simply signing up and making an account at github.com.
- After creating an account, the user may begin creating a repository by selecting the “Start a project” option.
- The user must next provide information about the repository they are about to establish.
- Each user has the option of creating a public (free) or private repository (which are paid).
How does it Work?
In a nutshell, GitHub is a website and cloud-based service, where you can save, share, and edit files with others at the same time, as well as track and control changes to it. Every file, folder, or project that you save to GitHub is referred to as a repository or “repo. “To fully grasp what GitHub is, you must first comprehend two interconnected principles:
- Version control
- Git
What Exactly Is Git?
- Linus Torvalds invented Git, an open-source version control system, in 2005.
- Git is a distributed version control system, which implies that every developer’s computer has access to the full codebase and history, allowing for easy branching and merging.
- Over 87 per cent of developers use Git, according to a Stack Overflow developer survey.
What Exactly Is Version Control?
Version control allows developers to track and manage changes to the code of a software project. Version control becomes increasingly important as a software project develops in size. Consider WordPress.
WordPress is a rather large project at this time. It would not be safe or economical to have a core developer directly modify the “official” source code if they wanted to work on a specific area of the WordPress codebase.
Version control, on the other hand, allows developers to securely work through branching and merging.
A developer uses branching to replicate a portion of the source code (called the repository). The developer may then safely modify that section of code without impacting the rest of the project.
The developer can then merge that code back into the main source code to make it official after he or she has got his or her section of the code operating properly.
All of these modifications are then tracked and, if necessary, reversed One of the most useful features is the ability to make a copy of the repo and keep it on your computer. This way, if you write code that doesn’t function, it won’t affect the program because you’re working on a copy of it. This is known as cloning a repo.
Branches:
Using GitHub branches, users may work on several versions of repositories at the same time. The default branch is referred to as the Master Branch, and the user can construct many sub-branches inside the Master Branch. The “Branch: master” dropdown option allows you to create sub-branches.
Assume you have a program code on your computer and are ready to begin working on a new feature. The first thing you should do is create a branch. A branch is another copy (of the copy) where you may work; the advantage of branching is that if you make a mistake, you can always go back to the original copy and start over.
The green segment is the primary copy or master, followed by the blue segment, which is a branch that is not yet a part of the green segment or major portion. Notice how the blue segment meets the blue segment at one point? Merging is the term for this. It’s critical to understand why the segment is made up of small circles; each circle represents a save called a commit; for example, say you’re 30% done with the new feature but want to work on it another day; you commit your changes(you save them); each commit will save the name of the person who did it, making it possible to return to those checkpoints at any time.
Merging:
Merging is the process of merging your modifications to the master branch. Assume you’ve completed the new feature. You’ll now need to merge all of the code you created into the main copy so that you can connect it all to the project. This step will automatically modify all of the code in the main branch and add all of the changes you made in the branches, merging the old code with the new code you edited.
Commit:
If a user wishes to add or edit something in a file, they may use the commit command to save their modifications. Any file may be changed by selecting “edit” and typing the changes in an editor window. After that, the user just has to click the “Commit changes” button to save the changes they’ve made.
Merge pull request:
You’ve worked hard to build the new feature, you’ve tested and perfected it, and you’re ready to integrate it into the project; this is where a pull request comes in. Because you’re requesting that your modifications be added to the main project, it’s termed “request.” Each repository has an owner or writer who is the only one who can approve modifications from others before they are added to the project. The owner, in this example, the main developer, will notice your pull request. He will then go through all of your code and test it to see whether it works; if it does, he will approve your request, and all of your code will be uploaded to the real project.
Conclusion:
GitHub is a fantastic platform that helps developers to work more efficiently and effectively. GitHub is so significant that companies use it to evaluate the quality of a candidate’s code. I hope this blog helps you grasp the concept and logic of GitHub; there are many more capabilities available on GitHub, such as hosting a website or following others to see their content. Thank you for your time!