π ³π °π 8: π ³π ΄π π Ύπ Ώπ π ΄π ½π Άπ Έπ ½π ΄π ΄ππ' π Άππ Έπ ³π ΄ ππ Ύ π Άπ Έπ π °π ½π ³ π Άπ Έππ ·ππ ±: π ΄π ½π ·π °π ½π ²π ΄ π ²π Ύπ »π »π °π ±π Ύππ °ππ Έπ Ύπ ½ π °π ½π ³ π ΄π ΅π ΅π Έπ ²π Έπ ΄
What is Git?
Git is a vital tool in modern software development, offering developers the power to track and manage changes to their code efficiently. Created by Linus Torvalds, Git ensures the integrity of software projects and allows for seamless collaboration. It's a distributed version control system (DVCS) that provides a historical record of all code changes, empowers developers to work offline, and simplifies the process of merging code contributions from various team members. Git's speed, security, and open-source nature make it a cornerstone of DevOps and software development, with platforms like GitHub enhancing collaboration and enabling continuous integration and deployment.
Aspects of Git
Version Control: Git tracks changes to files over time, allowing developers to see the entire history of modifications to a project. This makes it easy to revert to previous states, track who made changes, and understand when and why changes were made.
Distributed: Git is distributed, meaning that each developer working on a project has a complete copy of the repository. This allows them to work offline, make changes, and then synchronize (push/pull) their changes with other team members' copies.
Branching: Git makes it simple to create branches or divergent lines of development. Developers can work on new features, bug fixes, or experiments in isolated branches, which can later be merged into the main project when they are ready.
Collaboration: Git facilitates collaboration among multiple developers. They can work on different branches and merge their changes into the main project. Git hosting platforms like GitHub, GitLab, and Bitbucket offer tools for code review, issue tracking, and collaboration.
Speed and Efficiency: Git is designed to be fast and efficient. It only tracks changes, not entire files, and it uses a snapshot-based approach, making operations like branching and merging quick.
Security: Git employs cryptographic hashing to ensure the integrity of data. Each commit is identified by a unique hash, and changes to the codebase can be verified using these hashes.
Open Source: Git is open source, which means it is freely available and has a large community of users and contributors. It is widely adopted and supported on various operating systems.
To summarize it in short we can say that With Git, you can keep a record of who made changes to what part of a file, and you can revert to earlier versions of the file if needed. Git also makes it easy to collaborate with others, as you can share changes and merge the changes made by different people into a single version of a file.
What is GitHub?
GitHub is an essential web-based platform for developers, offering a collaborative space to efficiently manage software projects. Leveraging the powerful Git version control system, it supplements Git's capabilities with an intuitive web interface and robust collaboration tools. Explore the key features of GitHub below:
Git Hosting: GitHub is where you can store and share your code, making it accessible from anywhere.
Web Interface: GitHub provides an easy-to-use website for managing your code, eliminating the need for complex Git commands.
Collaboration: It allows multiple people to work together on a project, sharing their changes and ideas.
Issue Tracking: GitHub's built-in system helps you keep track of tasks, bugs, and feature requests.
Code Review: You can propose and review code changes before merging them into the main project.
Continuous Integration: GitHub integrates with testing and deployment tools for automated code testing.
Community: GitHub is a hub for developers to follow, contribute, and collaborate on various projects.
Documentation: You can document your project and create wikis to share information easily.
What is Version Control?
Version control is like a time machine for your files. It keeps track of changes you make to your work, so you can go back in time if something goes wrong. It's really helpful when many people are working on the same project.
There are 2 types of version control that are mainly used they are
Centralized version Control (CVS)
Decentralized Version Control (DVCS)
Centralized Version Control:
Centralized version control is like having a single, central hub where all your project's files and their histories are stored. Imagine a library where everyone borrows and returns books from the same place. Here's how it works:
Central Repository: There is a central server where all project files and their versions are kept. It's like the main library where all the books are stored.
Checkout: When a team member wants to work on a project, they "check out" a copy of the files from the central repository. It's like taking a book out of the library.
Editing: They can edit these files on their computer and save their changes.
Commit: Once they are done, they "commit" their changes back to the central repository. It's like returning the book to the library.
Conflict: If two people make changes to the same file at the same time, there can be conflicts that need to be resolved.
Distributed Version Control:
Distributed version control is like having your copy of the entire library and being able to make changes. Each person has a library with all the books. Here's how it works:
Local Copies: Everyone has a complete copy of the project's files and their history on their computer. It's like having your library at home.
Commit: Every Team member can make changes and "commit" them to their local copy. It's like making notes or highlighting in your books.
Push and Pull: They can share their changes with others by "pushing" and "pulling" from each other's libraries. It's like sharing your book annotations with friends and borrowing their notes.
Conflict Resolution: If there are conflicts between changes, they can be resolved by merging the different versions.
Backup: Since everyone has a copy, there's a backup if the central repository or someone's computer crashes. It's like having copies of the books at different places.
Distributed version control gives each team member more independence and flexibility, while centralized control relies on a central hub for coordination.
Why do we use a Distributed Version Control System over a Centralized Version Control System?
We use a Distributed Version Control System (DVCS) over a Centralized Version Control System (CVCS) for several reasons:
Work Anywhere: With DVCS, you can work on your code even without the internet, while CVCS often needs an internet connection.
Speed: DVCS is usually faster for common tasks like saving your changes, making new branches, and combining changes. CVCS can be slower because it relies on a central server.
Backup: In DVCS, everyone has a full copy of the project, so it's like having multiple backups. In CVCS, if the central server has problems, the project could be in trouble.
Flexible Teamwork: DVCS lets team members work on their own without causing trouble for others. You can even experiment with your code separately. CVCS requires more coordination to avoid conflicts.
Branching and Merging: DVCS makes it easier to create different versions of your code and merge changes. CVCS can be more complicated in this regard.
Large Teams and Long Distances: DVCS is better for big teams and when team members are far apart because everyone has their complete copy of the project.
Security: Even if the central server is hacked in DVCS, your work is safe on your computer. In CVCS, if the central server is compromised, it's riskier.
In summary, while both DVCS and CVCS have their use cases, DVCS provides more flexibility, resilience, and efficiency, making it a preferred choice for many modern software development teams, particularly those working on large and distributed projects.
Sign up on GitHub
Create a new repository in GitHub
Clone a new repository on your local system
Make some changes to a file in the repository and commit them to the repository using Git.
Push the changes back to the repository on GitHub
How to do a basic git setup?
open your terminal and paste the following commands
git config --global user.name "your username"
git config --global user.email "your email"
Create Repo
Make Some changes and commit
git add *
# using * at the end will add everything to the stack to push to main repo
git commit -m " Messeage/Comment"
git push orgin main
Changes are Pushed to github