Table of contents
- What is Git?
- What is GitHub?
- Version control system and its types
- Why do we use distributed version control over centralized version control?
- Task 1:Install Git on your Computer.
- Task 2: To create a free account on GitHub.
- Task 3: To create a repository on GitHub and clone it on your local machine.
- Task 4: Make some changes to a file in the repository and commit them to the repository using Git.
- Task 5: Push the changes back to the repository on GitHub.
- Thanks for reading!
What is Git?
GIT can be defined as the “Global Information Tracker,” a powerful version control system widely used for software development and other collaborative projects. GIT allows multiple developers to work on a project simultaneously while ensuring that their changes do not interfere with one another. It was created by Linus Torvalds in 2005
Git provides the best performance when it comes to version control systems. Committing, branching, and merging all are optimized for a better performance than other systems. Git is a DevOps tool used for source code management. It is a free and open-source version control system used to handle small to very large projects efficiently. Git is used to track changes in the source code, enabling multiple developers to work together on non-linear development.
What is GitHub?
GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. They provide a platform to store and manage code, share projects with other people, collaborate on coding projects and much more. Repositories also allow developers to keep track of the changes they have made in their code over time so they can quickly go back if needed.
Version control system and its types
Version control - also known as source control or revision control - is an important software development practice for tracking and managing changes made to code and other files. It is closely related to source code management.
There are two main types of version control:
Centralized Version Control System (CVCS): A centralized version control system has a single server that contains all the file versions. This enables multiple clients to simultaneously access files on the server, pull them to their local computer or push them onto the server from their local computer. This way, everyone usually knows what everyone else on the project is doing. Administrators have control over who can do what.
Distributed Version Control System (DVCS): With distributed version control systems, clients don’t just check out the latest snapshot of the files from the server, they fully mirror the repository, including its full history. Thus, everyone collaborating on a project owns a local copy of the whole project, i.e. owns their own local database with their complete history. With this model, if the server becomes unavailable or dies, any of the client repositories can send a copy of the project's version to any other client or back onto the server when it becomes available. It is enough that one client contains a correct copy which can then easily be further distributed.
Why do we use distributed version control over centralized version control?
Distributed version control systems (DVCS) have gained popularity and are often preferred over centralized version control systems (CVCS) for several reasons:
Decentralization: In a DVCS, every developer has a full copy of the entire repository, including the entire history of the project. This decentralization means that developers can work independently, even without a network connection. In a CVCS, developers are more dependent on a central server for most operations.
Offline Work: DVCS allows developers to work offline, which is particularly beneficial when they are on the go or have a slow or unreliable internet connection. They can commit changes, switch branches, and perform various other operations without needing to be connected to a central server.
Faster Operations: DVCS systems often perform faster for common operations like commits, branching, and merging. Since most actions are done locally, they don't depend on network latency or server performance.
Parallel Development: Developers can create branches and work on their own features or bug fixes in isolation without interfering with each other. This is especially valuable for larger teams and complex projects.
Branching and Merging: Branching and merging are fundamental to version control. DVCS makes branching and merging easier and more flexible. Developers can create feature branches, work on them, and merge changes into the main branch when they are ready, allowing for a more controlled and organized development process.
Security: In a DVCS, since each developer has a complete copy of the repository, there is less risk of data loss due to a central server failure. Developers also have more control over their local repositories and can implement security measures as needed.
Collaboration: Collaboration is more flexible in DVCS. Developers can share changes by pushing their local repositories to various remote repositories, enabling distributed and asynchronous collaboration. Multiple remote repositories can be set up to facilitate different workflows or collaborations with different teams.
Forking: In DVCS, forking a project is a common practice. Developers can create their own copies of a repository, make changes, and even propose those changes back to the original project. This is widely used in open-source development and encourages community contributions.
Task 1:Install Git on your Computer.
To install Git on your computer we need to go to the site i.e git-scm.com/downloads.
Here you can select your respective Operating System and download Git.
Task 2: To create a free account on GitHub.
Open, github.com and click on “Sign Up” and enter your details. Your account will be created.
Task 3: To create a repository on GitHub and clone it on your local machine.
First, we need to create a repository on GitHub, create a file to clone it to our local machine and commit it. Then we use the command i.e. git clone repo_url
to clone the files from GitHub to the local machine.
Task 4: Make some changes to a file in the repository and commit them to the repository using Git.
First, we created a file then we committed it using git then we made some changes to the file and we will again commit it to git using git status
command.
Task 5: Push the changes back to the repository on GitHub.
To push the files that we created on our local machine to GitHub we will use the git push origin master
We can check the files whether the files are uploaded to the GitHub repository or not.
Thanks for reading!
#devops #TrainWithShubham
Let's connect on Linkedin- https://www.linkedin.com/in/piyush-verma-8b1b4426a/