Task 8 of #90daysofdevops challenge
What is Git?
Git is a free and open-source version control system tool used to handle small to very large projects efficiently.
It is generally used for source code management in software development.
Git is used to tracking changes in the source code.
It allows multiple developers to work together. It supports non-linear development through its thousands of parallel branches.
What is Github?
GitHub is a web-based platform that provides hosting for version control using Git. It offers all of the distributed version control and source code management (SCM) functionality of Git with its add-on features.
GitHub is a very popular platform for developers to share and collaborate on projects, and for hosting open-source projects from anywhere.
What is Version Control? How many types of version controls?
Version control systems are a category of software tools that helps in recording changes made to files by keeping a track of modifications done in the code.
It helps in reverting files to a previous state, reverting the entire project to a previous state, comparing changes over time, seeing who last modified something that might be causing a problem, who introduced an issue and when, and more.
Types of version controls:
A centralized version control system (CVCS): uses a central server to store all the versions of a project's files.
e.g. Subversion and Perforce.
A distributed version control system (DVCS): allows developers to "clone" an entire repository, including the entire version history of the project.
e.g. Git, Mercurial, and Darcs.
Why do we prefer distributed version control over centralized version control?
Better collaboration
Improved speed
Greater flexibility
Enhanced security
Excercise:
Install Git on your local system (if it is not already installed). You can download it from the official website at git-scm.com/downloads
Create a free account on GitHub (if you don't already have one). You can sign up at github.com
Create a new repository on GitHub and clone it to your local machine
To create new repository in GitHub, go to 'your repositories' in profile and press
new
button on top right corner. This will let you to following pagePut here your repository name which is unique, add description if you want.
Click public so that repo will be accessible to anyone.
You can add README File to showcase what's this repo is all about & here is your repo created successfully.
Now get inside the repo and press
add file
dropdown it and choose create new filefile.txt
andrepo_list.md
Now clone this repository by using command
git clone https://github.com/<username>/<repository-name>.git
Make sure the directory at which you want to initializes the git .
Make some changes to a file in the repository and commit them to the repository using Git
Make any changes in files and check the status as below
(In this, file listed in red that means it must be added to the repository)
Now add this changed file & commit this changes to the repository by using command
git add . && git commit -m "modified the file"
Push the changes back to the repository on GitHub by using command
git remote add origin <repository-name> && git push origin master
Thus if refresh github we can see it gets updated.
That's all.
Reference video: https://youtu.be/AT1uxOLsCdk
Reference articles for commands: https://www.geeksforgeeks.org/top-12-most-used-git-commands-for-developers/
Thanks for reading.
Keep learning & stay connected!!