What is Git?
Git is a version control system that helps you manage your source code and track changes made to it. It's a command-line tool that you can use to keep track of different versions of your files, collaborate with others, and coordinate work on software projects.
What is GitHub?
GitHub is a web-based platform for hosting and managing Git repositories, which are used for version control. However, it's widely used by Linux users and developers.
Here's what GitHub does:
Hosting Git Repositories: GitHub allows users to store their Git repositories remotely on its servers. This means you can access your code from anywhere with an internet connection.
Collaboration: GitHub makes it easy for multiple people to work on the same project. It provides tools for managing issues, reviewing code, and coordinating work among team members.
Community and Open Source: GitHub hosts millions of open-source projects, making it a hub for developers to collaborate, contribute, and discover new projects.
Documentation and Wikis: GitHub provides features for documenting projects, including wikis and project pages, which can be helpful for explaining how to use the software, contributing guidelines, and more.
Integration with Other Tools: GitHub integrates with a wide range of third-party services and tools, such as continuous integration systems, project management tools, and code editors, making it a central hub for many development workflows.
GitHub is a platform that enhances the capabilities of Git by providing additional features for collaboration, community building, and project management. While it's not specific to Linux, it's widely used within the Linux community and beyond.
What is Version Control? How many types of versions control we have?
Version control is a system that records changes to a file or set of files over time, so that you can recall specific versions later. It enables you to keep track of modifications, revert to previous stages, and work collaboratively with others on a project.
There are primarily two types of version control systems:
Centralized Version Control Systems (CVCS):
In a CVCS, there is a single central repository that stores all the files and their versions.
Users check out files from this central repository to make changes, and then check them back in when done.
Examples of CVCS include Concurrent Versions System (CVS) and Subversion (SVN).
Distributed Version Control Systems (DVCS):
In a DVCS, every user has their own local repository, which contains the entire history of the project.
Users can work independently and make changes to their local repository without needing constant access to a central server.
Changes can be shared and synchronized between repositories as needed.
Examples of DVCS include Git, Mercurial, and Bazaar.
Git is one of the most popular DVCS, known for its speed, flexibility, and powerful branching and merging capabilities. It's widely used in both open-source and commercial projects.
Why we use distributed version control over centralized version control?
There are several reasons why distributed version control systems (DVCS) like Git are often preferred over centralized version control systems (CVCS) like Subversion (SVN):
Offline Work: With DVCS, users have their own local copy of the entire repository, which allows them to work offline. This flexibility is particularly useful for developers who may need to work in environments with limited or no internet access.
Faster Operations: DVCS operations are typically faster because they are performed locally. With CVCS, every operation involves communication with a central server, which can introduce latency, especially for operations like commits, updates, and merges.
Flexible Branching and Merging: DVCS systems like Git have powerful branching and merging capabilities. Branches are lightweight and can be created and merged quickly, enabling a more flexible and agile development workflow.
Better Collaboration: DVCS encourages a more distributed and collaborative workflow. Developers can work independently on their local repositories and share changes with others through pushes and pulls.
Redundancy and Backup: Since every developer has a complete copy of the repository, DVCS provides built-in redundancy and backup. This redundancy helps ensure the integrity and availability of the project's history and codebase.
Overall, DVCS offer greater flexibility, speed, and resilience compared to centralized systems, making them well-suited for modern software development practices.
Task:
1. Install Git:
Install git if it is not in your computer, to download follow these steps:
• Visit the official website at https://git-scm.com/downloads.
• Choose your operating system (Windows, Linux, macOS) and Download.
2. Create a GitHub Account:
Create a GitHub Account if you don't have, follow these steps to create:
• sign up at https://github.com/
• Enter the details like- username, email address, and password.
• Complete the account creation process.
Exercises:
Create a new repository on GitHub and clone it to your local machine:
Now you have Git installed and a GitHub account:
Login to your GitHub account.
Click on the "+" sign in the upper right corner and choose "New repository."
Enter your Repository name, add a description if you want, and click on the "Create repository" button.
Once created, click the green "Code" button, copy the <repository URL>
Open your terminal, and use the command:
git clone <repository URL>
Make some changes to a file and commit them using Git:
Go to the cloned repository on your local machine.
Add a new file or make changes to an existing file.
Open your terminal, navigate to the repository, and use the following commands:
git status # View the changes git add <filename> # Stage the changes git commit -m "Your commit message here" # Commit the changes
Push the changes back to the repository on GitHub:
After committing changes locally, it's time to push them to your GitHub repository.
Use the following command:
git push origin main # Push changes to the 'main' branch (adjust branch name if needed)
Refresh your GitHub repository page, and you should see the changes reflected.
This is the #Day08 of the #90DaysofDevOps challenge! Hope you found this article informative and useful so please share it with others who might benefit from it.
Thanks for reading this article.
Keep Learning...