Basic Guide on Git and GitHub
Today we're going to go through and explain how you can use Git for your software development. In this article we will introduce the concept of version control that you will use within your DevOps environment. As you may already know that there are different tools available in a distributed version control system. This article will highlight the products called Git and Github, which are typically used for version control. What are the differences between both of these? All the concepts, how you pull, push, commit, then how do you push the code in the Github, how do you make repo over there. Firstly, lets understand what is Git and what is Github;
In this article, we will introduce the concept of version control that you will use within your DevOps environment. As you may already know that there are different tools available in a distributed version control system. This article will highlight the products called Git and Github. Which are typically used for version control.?
What is GIT??
It's an open-source version control system created by Linus Torvalds in 2005. It's a distributed version control system which means that the entire codebase and history of the project is available on every developer's computer which allows for easy branching and merging. It helps to track the changes in the source code, enabling various people to collaborate on varied parts of the same program.
To explain this in simple language, Git enables the developers to have a local copy of a code with complete history. One copy of that code is also kept on the server.? So whenever you make changes to your local copy, you just have to push the changes on the server and the other developers can pull the changes from there.
What is GitHub?
Github is a web-based version-control and collaboration platform for software developers. It facilitates social coding by providing a web interface to the git repository and management tools for collaboration. The interface of this platform is tremendously user-friendly so even new coders can take advantage of it.?
Imagine working on a project in which you are stuck with some code and you are out of your home and you suddenly remember a solution for that code error. Now, if you don't have your PC with you, how can you make these changes instantly? Here comes the need of GitHub. If you have your project hosted on GitHub, you can easily download and access that project file on whatever computer you have access to. Then you can make the required changes and push the latest version back to GitHub. One more awesome feature of GitHub is its ability to collaborate with other developers from any place.
Some Key Features of GitHub:
- Repositories
- Branches
- Commits
- Pull Requests
Repository: A GitHub/Gitlab repository is used to store a project. It can contain folders or any type of files like (HTML, CSS, JavaScript, Documents, Data, Images). Here, one important thing you should include is the license file and a README file with your project for details and instructions.
领英推荐
Branches: A branch essentially is a unique set of code changes with a unique name. Each repository can have one or more branches. By default a repository has a master branch. Any other branch is a copy of the master branch. New Branches are for bug fixes and feature work separate from the master branch. When changes are ready, they can be merged into the master branch.
Commits: On GitHub/Gitlab, changes are called commits. Each commit has a description of why a change was made for future reference and better documentation of the process.
Pull Requests: Pull Requests are the heart of GitHub collaboration. Pull requests let you tell others ( team members) about changes you've pushed to a branch in a repository on GitHub. Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes are merged into the base branch.
Basic Git Commands:
Git init - The Git init command creates a new Git repository git status - At any point, you can type ‘git status’ to know the status of your git repo folder. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git.
Git add (file-name.extension) - The second step is to enter this command followed by the filename and its extension. You can also use this command if there are multiple files you want to upload to GitHub.
Git commit -m "commit-message" - Now IF you have added your files and made your changes, you need to commit your changes so git can track them.You need to write a message in commit; it not just help you identify a commit, but also enable you to understand what you did with the file at that point.
Git revert: This command creates a new commit that undoes the changes from a previous commit. This command adds new history to the project (it doesn't modify existing history).
Git checkout: This command checks-out content from the repository and puts it in your work tree. It can also have other effects, depending on how the command was invoked.
For instance, it can also change which branch you are currently working on. This command doesn't make any changes to the history.
Final Thoughts:
I hope this blog helped you understand Git and Github. If you have read the blog carefully, congratulations, you are good to use these in your project. It doesn't matter whatever language you are using. Being the most popular version control system in the world, both of them are sure requirements to learn for working in a good software development company. I hope this blog? is informative. Feel free to share any feedback you may have.