Day-08 Task: Basic Git & GitHub for DevOps Engineers
Describe Git
Git is a version control system that lets you keep track of file changes and divide up work among several users. While it may be used to track changes to any set of files, it is most frequently used for software development.
Git allows you to easily track who has changed what in a file and roll back to previous iterations when necessary. Git also facilitates collaboration by allowing you to exchange changes and combine several users' edits into a single file version.
Explain GitHub
GitHub is an online platform that hosts Git version control systems. It is a Microsoft subsidiary that provides all of Git's distributed version control and source code management (SCM) features in addition to a few extras. Open-source projects are hosted on GitHub, a widely used site for developers to exchange and work together on projects.
Version control: what is it? How many different kinds of version controls are there?
A version control system keeps track of modifications made to a file or group of files over time, enabling you to recall particular versions at a later time. It lets you undo changes over time, check who last changed something that might be causing an issue, who introduced an issue and when, and much more. You can even roll back files to a previous state or the entire project.
Centralized and distributed version control systems are the two primary categories of version control systems.
Centralized version control system (CVCS): This system stores all of a project's file versions on a single server. Once they have made modifications, developers "check out" files from the central server and "check in" the revised versions. Perforce and Subversion are two instances of CVCS.
Distributed version control system (DVCS): It enables developers to "clone" a repository in its entirety, together with the project's version history. This indicates that they have an entire local copy of the repository, including all previous iterations and branches. Developers can work individually and then subsequently merge their modifications back into the main repository. DVCSs include Darcs, Mercurial, and Git.
Why is distributed version control preferable to centralized version control?
Better collaboration: Every developer using a DVCS has access to a complete copy of the repository, which contains the whole history of all modifications. Because they no longer need to continuously contact a central server to commit their modifications or view those of others, developers may now collaborate more easily.
Improved speed: Developers can commit changes and carry out other version control tasks more quickly since they have a local copy of the repository and don't need to interact with a central server.
Greater flexibility: Developers can work offline with a DVCS and commit their changes later when they are online. Instead of uploading all of their modifications to a single server, they can decide to share their changes with a specific portion of the team.
Enhanced security: The repository history in a DVCS is more resilient to data loss because it is kept on several servers and PCs. Recovering lost data from a CVCS might be challenging if the repository becomes corrupted or the central server goes down.
Overall, Decentralized distributed computing systems (DVCSs) are a popular option for numerous teams due to their ability to facilitate increased security, flexibility, and collaboration.
Exercises:
Create a new repository on GitHub and clone it to your local machine.
Log in to your GitHub account or create a new GitHub account if you don't have it.
Then under Repository click on new
Enter your repository name and click on the Create Repository button at the bottom.
Then click on Add file it will ask file name so after entering the file name with an extension it will create the file.
Click on the Code button and copy the URL from the HTTPS tab.
Now login to your local system and run clone command.
To clone the remote repository locally use the next command
#git clone <your repository url>
#git clonehttps://github.com/mominirfan1990/first-git-devops-repo.git
Make some changes to a file in the repository and commit them to the repository using Git
#git add my_second.txt
#git commit -m "latest changes by dev"
Push the changes back to the repository on GitHub.
Here we used Token based authentication instead of entering username and password manually
Generate token on GitHub account following next steps
Used next command to token-based authentication
#git remote set-url origin https://token@GitHubRepositoryUrl.git
#git push origin main
Subscribe to my newsletter
Read articles from Irfan S Momin directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Irfan S Momin
Irfan S Momin
A Foodie Software Engineer's Journey to Eating Healthy and Learning Something New Every Day