Version Control: Git & GitHub

Explore About Git, The Developers Backbone.

·

4 min read

Version Control: Git & GitHub

About Me:

Hey Folks! Am Vishwa, DevOps and OpenSource Enthusiast. Currently am doing LearnInPublic and BuildInPublic where I'll be documenting my entire journey on LinkedIn and Twitter to be accountable and to connect with many like-minded people to seek knowledge from them and help each other. Here we are going to look at the version control system. Git is very famous for that. Let's start our learning.

What is a Version Control System?

- It is nothing but a software tool that is used to maintain the changes made in the files or documents.

- It helps people to collaborate & work on the project.

- It keeps track of records which is the history of changes.

- Easy to recover the codebases, if the code is crashed after making some changes.

- Git & GitHub is used for these purposes.

What is Git & GitHub?

- Git is nothing but a CLI which is a Command Line Interface used to track/make changes in GitHub.

- GitHub is a web-based platform that serves as a central for developers to collaborate on projects for making contributions.

- We can do the things in GitHub web itself but using Git CLI is the best practice.

Things We do using Git:
1. Repository Hosting:

- It is a collection of documents, files and folders which holds the source code in it.

2. Commits:

- It is nothing but if we make any changes in the repository then that counts as a commit.

3. Branches:

- Developers can create as many branches as they want, it is useful when everyone is working on separate features or bugs.

- Creating a sub-branch & making changes in the codebase is good practice.

- Each & every repo has a Main(Master) branch in it. Sub-branches can be merged later.

4. Merging:

- It is all about combining one branch with another branch.

- GitHub handles conflicts too which is nothing but when changes arise from different branches, conflict occurs.

5. Pull Request:

- It is the main thing in GitHub, which is used to push the changes.

- It is done before merging any changes to the main codebase.

- The main use case of making a PR is to do a code review, testing and also
for discussion.

6. Forks:

- It is nothing but a copy of the project, which comes/forked under your username.

- We should always make changes by forking the original project, later the forked one will be merged.

7. Cloning:

- It is about creating a copy of the project on the local machine & easy for developers to make changes offline.

8. Pull, Fetch & Pushing:

- Fetching is nothing but the changes made in the remote repo

- Pulling is about merging the changes made in the remote(online) repo & with the current offline file.

Installation:

- Install git bash for Windows & by using package manager install it on Linux/Unix operator.

Download Git Here

- We can download GitHub desktop too

Steps:

1. Create a repo in our GitHub Account:- Once you're logged in to your GitHub account, you can create a new repository by clicking the "+ New" button on the top right corner of the GitHub dashboard. Give your repository a name, and optional description, choose public or private visibility, and add any other desired settings.

2. Cloning the repository:- Once created, clone the repo to your local machine with the help of the remote repo's URL which is the actual URL.

- $git clone <repository url>

3. Create a sub-branch and make changes:- Navigate to the cloned folder, make changes or modify the files as we want.

-$ git checkout -b new-branchname

4. Staging Area:- It is nothing but making the changes ready for the next commit.

-$git add.

5. Reviewing the changes:- Once the change is made, we need to check whether the file is modified or not.

-$git status

6. Committing the changes:- If the change is made, commit the changes with a commit message for better understanding/collaboration.

-$git commit -m "Commit Message"

7. Pushing the changes: Once changes are committed, push them to the remote repo.

-$ git push origin sub-branchname

Here origin is the main, which holds the remote repos link & sub-branch is the one where we make changes.

8. Pulling the changes:- If some changes are made in the remote repo that need to be merged in the local directory means will di fetching & merging.

-git pull origin main

Here the main branch of the origin is fetched & merged with our existing cloned directory.

Conclusion:

This is all about Git & GitHub folks. Thanks for reading it. Hope you guys enjoyed reading it. Please do share, like & provide feedback in the comment section guys for better reach. Will see you in the next article with amazing content.

HappyLearning Folks!

Did you find this article valuable?

Support VISHWA S by becoming a sponsor. Any amount is appreciated!