Git- Mastering The Version Control.
Why Git.. before What Git !!
Lets understand the problem;
Suppose we are asked to make Subject project Called Library Management System for the subject of DBMS. You are in group of 5 members,everyone is assigned with respective tasks. To start their adventure, the friends create a central repository, a virtual library, where they store all their project files. Git ensures that every change made to the files is carefully recorded, creating a detailed history of the project’s evolution.
Every member can have their separeate path of devloping called Branches.
If certain feature is not working due to some bug by the code done by other member, we can revert back to the lower version and can keep a track of initial to final project.
What is Git :
Git is a free, open source distributed version control system tool designed to handle everything from small to very large projects with speed and efficiency. It was created by Linus Torvalds in 2005 to develop Linux Kernel. I hope this blog will help you get better understanding of Git.
Downloading and Installing Git:
Head over to the official Git website at https://git-scm.com/downloads.
Once there, you’ll find the Git installer tailored to your specific computing platform (Windows, macOS, or Linux). Click on the download link for your platform to get started.
After the download completes, locate the installer file and run it.
Follow the installation steps provided by the installer. It will guide you through the process, allowing you to customize the installation options if desired.
As you go through the installation, you may also consider installing Git GUI tools like GitHub Desktop, which will automatically include Git during its installation.
Once the installation is complete, you can confirm that Git has been successfully installed by opening a command prompt or terminal window on your computer.
In the command prompt or terminal, type “git — version” (without quotes) and press Enter. If Git has been installed correctly, it will display the version information.
git version
If the cmd gives the version of git after the command then we have successfully downloaded the Git.
Git general terms :
Git: A decentralized and open-source version control system that tracks changes in code repositories.
GitHub: A collaborative platform where users can host and collaborate on Git repositories, facilitating team collaboration and project management.
Commit: A record of changes made to a Git repository, capturing a snapshot of the project’s state at a specific point in time.
Branch: A parallel line of development within a Git repository, allowing for separate workstreams without affecting the main codebase.
Clone: Creating a local copy of a Git repository, including all commits and branches, enabling individual work and synchronization with the remote repository.
Remote: A separate copy of a Git repository hosted on a server, typically on platforms like GitHub, allowing team members to exchange and synchronize their changes.
Git Commands:
git config : This command sets the author name and email address respectively to be used with your commits.
When using Git, you can configure settings at both the local repository level and the global level. The
--global
option is used to specify that the configuration should be applied globally, affecting all repositories on your machine.Local Settings:
Local settings are specific to a particular Git repository. When you configure settings locally, they are stored in the
.git/config
file within the repository.Local settings take precedence over global settings if there is a conflict. This means that if a configuration is set both locally and globally, the local setting will override the global one within that particular repository.
Local settings are ideal for repository-specific configurations. For example, you might want to set the username and email address to be used for commits in a specific repository.
cd /path/to/repository git config user.name "Your Name" git config user.email "your@email.com"
Global Settings:
Global settings apply to all Git repositories on your machine. They are stored in the
.gitconfig
file in your home directory.Global settings provide a convenient way to set configurations that apply universally to all your repositories. For example, you can set your preferred text editor, default commit message template, or default branch name.
commands :
git config -global user.name[name]
git config -global user.email[email]
- git init: Git init initializes a new Git repository in the current directory
commands :
git init
3. git add : Git add stages changes, preparing them to be included in the next commit
git add .
3 . git commit :Git commit captures a snapshot of the current project state and saves it as a new revision in the repository. There is option of sending a message with -m option example git commit -m “Feature added”.
git commit -m "FeatureAdded"
4.git diff : Git diff shows the differences between the current state of the code and the last commit
git diff
5. git clone : A local version of a repository that includes all commits and branches is called a “clone.” suppose we have a Remote code base and we want to have local copy of that code.
git clone
We can see after cloning the remote react-shopping-cart repository to the local system.
Now there are more advanced terminologies such as git push, git pull, fork of a repository but for using such advanced commands we need a knowledge of GitHub that we will be covering in the next blog.
What are we going to cover in the next blog:
More Advanced git commands with github 🚀
Working with github Repositories🚀
Creating our first pull request on github🚀
Thank you!! Lets connect .
Socials :
Subscribe to my newsletter
Read articles from Jiyan Patil directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Jiyan Patil
Jiyan Patil
🚀 Second-year Computer Science student at VIT Pune 🧠 Passionate about Software Engineering and Problem Solving 💻 Expertise in JavaScript, MERN stack, Python, and DevOps 🔗 Strong foundation in Data Structures and Algorithms ⚙️ Committed to crafting efficient and scalable solutions 🌟 Dedicated to tackling complex challenges head-on