Table of contents
- 🔹What is Git?
- 🔹What is GitHub?
- 🔹What is Version Control? How many types of version controls do we have?
- 🔸Centralized version control systems:
- 🔸Distributed Version Control Systems:
- 🔹Why do we use distributed version control over centralized version control?
- 🚀Task:
- 🔹Create a GitHub Account:
- 🔸Exercise 1: Create a New Repository on GitHub
- 🔸Exercise 2: Clone the Repository to Your Local Machine
- On the repository page, click the green "Code" button.
- 🔸Exercise 3: Make Changes, Commit, and Push
🔹What is Git?
Git is a version control system that allows you to track changes to files and coordinate work on those files among multiple people. It is commonly used for software development, but it can be used to track changes to any set of files.
With Git, you can keep a record of who made changes to what part of a file, and you can revert back 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.
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 is a subsidiary of Microsoft, and it offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features. GitHub is a very popular platform for developers to share and collaborate on projects, and it is also used for hosting open-source projects.
GitHub lets you store your repo on their platform. Another awesome feature that comes with GitHub is the ability to collaborate with other developers from any location.
🔹What is Version Control? How many types of version controls do we have?
Version Control Systems are process management systems that maintain changes recorded in a file or set of files over a period of time. Each change is maintained as a version. Users can track specific versions later. Version control systems do not require any other repository systems and can be cloned as per the need and availability. This is extremely helpful in case of failure and accidental deletions.
There are two main types of version control systems:
Centralized version control systems
Distributed version control systems.
🔸Centralized version control systems:
Centralized version control systems contain just one repository globally and every user needs to commit to reflecting one’s changes in the repository. It is possible for others to see your changes by updating.
Two things are required to make your changes visible to others which are:
commit
update
🔸Distributed Version Control Systems:
Distributed version control systems contain multiple repositories. Each user has their own repository and working copy. Just committing your changes will not give others access to your changes. This is because commit will reflect those changes in your local repository and you need to push them in order to make them visible on the central repository. Similarly, When you update, you do not get others’ changes unless you have first pulled those changes into your repository.
To make your changes visible to others, 4 things are required:
commit
push
pull
update
🔹Why do we use distributed version control over centralized version control?
Better collaboration: In a DVCS, every developer has a full copy of the repository, including the entire history of all changes. This makes it easier for developers to work together, as they don't have to constantly communicate with a central server to commit their changes or to see the changes made by others.
Improved speed: Because developers have a local copy of the repository, they can commit their changes and perform other version control actions faster, as they don't have to communicate with a central server.
Greater flexibility: With a DVCS, developers can work offline and commit their changes later when they do have an internet connection. They can also choose to share their changes with only a subset of the team, rather than pushing all of their changes to a central server.
Enhanced security: In a DVCS, the repository history is stored on multiple servers and computers, which makes it more resistant to data loss. If the central server in a CVCS goes down or the repository becomes corrupted, it can be difficult to recover the lost data.
Overall, the decentralized nature of a DVCS allows for greater collaboration, flexibility, and security, making it a popular choice for many teams.
🚀Task:
1)Install Git on your linux terminal
Open your Linux terminal.
Depending on your distribution, you can use a package manager to install Git. For example, on Ubuntu-based systems:
sudo apt-get update
sudo apt-get install git
- Verify the installation by typing
git --version
🔹Create a GitHub Account:
Open your web browser and go to github.com
Click on the "Sign up" button.
Provide the required information, such as username, email, and password.
Complete any necessary verification steps.
By following these steps on your Linux system, you'll have Git installed, and a GitHub account created.
🔸Exercise 1: Create a New Repository on GitHub
Log in to your GitHub account.
Click on the '+' icon in the top-right corner and select "New repository."
Fill in the repository name, a description (optional), and other settings.
Choose between making the repository public or private.
You can choose to initialize the repository with a README, which is recommended for starting projects.
Click on the "Create repository" button.
🔸Exercise 2: Clone the Repository to Your Local Machine
On the repository page, click the green "Code" button.
- You can either choose to clone with HTTPS or SSH. Choose the one that suits your preference. Click the clipboard icon to copy the URL.
Open your terminal on your local system.
Navigate to the directory using cd command where you want to clone the repository
Use the git clone command followed by the repository URL to clone the repository.
git clone <paste_the_copied_url>
Press Enter to execute the command.
If the repository is private, GitHub might ask for a username and password.
Once the repository is cloned, you will have a copy of the GitHub repository on your local system.
- Before you can start using Git, you need to configure it. This command allows you to specify the username and email address that will be used with your commits.
🔸Exercise 3: Make Changes, Commit, and Push
Open the Git bash from the folder /repo you wish to add to the version control system(git)
a. Create a Directory and Initializes it
b. Create a file and add it to a local repo
c. Now if you your file is ready to commit, you can see the status as well.
d. You can see where this file is now ready to commit. so just commit to it
e. Now if you again check Git Status it will blank because there is no file left to commit
Push the changes back to the repository on GitHub by using the command
git remote add origin <repository-name> && git push origin master
The command “git push origin main” is used to push the changes made locally and committed to the remote repository specified.
Thanks for reading to the end; I hope you gained some knowledge.❤️🙌