1. What is Git π
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. Also, the version control system (VCS) enables one to store code, track revision history, merge code changes, and revert to earlier code versions when needed.
In simple terms, Git is a version control system. In the case of the version control system, the code is saved on the cloud. The cloud is basically a remote machine that is much more reliable than a local computer. So there is nothing to the chance of loss of data by a subsequent system crash. Also, multiple people can contribute to the same code without any conflict. There are different types of version control systems presently in our market that is git, subversion, and mercurial. But Git is by far the best version control system and GitHub is the very popular website to host code that is also based on git.
2. Version control π©βπ»
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.
If you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use. It allows you to revert selected files back to a previous state, revert the entire project back to a previous state, compare changes over time, see who last modified something that might be causing a problem, who introduced an issue and when, and more. Using a VCS also generally means that if you screw things up or lose files, you can easily recover them. In addition, you get all this for very little overhead.
Local Version Control Systems
Many peopleβs version-control method of choice is to copy files into another directory. This approach is very common because it is so simple, but it is also incredibly error-prone. It is easy to forget which directory youβre in and accidentally write to the wrong file or copy over files you donβt mean to. To deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control.
Centralized Version Control Systems
The next major issue that people encounter is that they need to collaborate with developers on other systems. To deal with this problem, Centralized Version Control Systems (CVCSs) were developed. These systems have a single server that contains all the versioned files, and a number of clients that check out files from that central place. For many years, this has been the standard for version control.
Distributed Version Control Systems
In a distributed version control system, every developer has a full copy of the project and project history. Unlike once popular centralized version control systems, DVCSs don't need a constant connection to a central repository. Git is the most popular distributed version control system. Git is commonly used for both open-source and commercial software development, with significant benefits for individuals, teams and businesses.
3. Git Workflow β
A Git workflow is a recipe or recommendation for how to use Git to accomplish work in a consistent and productive manner. Git workflows encourage developers and DevOps teams to leverage Git effectively and consistently.
4. Integration git with GitHub π
GitHub hosts Git repositories and provides developers with tools to ship better code through command line features, issues (threaded discussions), pull requests, code reviews, or the use of a collection of free and for-purchase apps in the GitHub Marketplace. With collaboration layers like the GitHub flow, a community of 100 million developers, and an ecosystem with hundreds of integrations, GitHub changes the way software is built.
5. Basic Git Commands </>
How to clone a GitHub repository to git version control (NOTE: The URL change every time)
Get the status of the git repository
- It will add the file to the staging area. Later on, the staging area will be used to commit files when you run the git commit. (NOTE: This example takes a Python file name as myfile)
Undo the changes to the local files, and restore the last commit.
Initializes a new git repository
Used to list all the local branches on the machine.
Used to create a new branch locally.
Used to delete a branch.
Used to rename the current working branch.
Merges the provided branch with the current working branch.
Used to switch from the current branch to another one.
Creates a new branch and switches to the new one.
Used to remove a file from the working directory.
It is used to temporarily remove uncommitted changes.
git commit adds your changes to the local version control database. You have still not pushed these changes to a remote server(GitHub)
- It shows all of the commit histories
- It will now push committed changes to a remote server(GitHub)
It is used to fetch and merge any commits from the tracking remote
branch
It shows the difference between your local changes and the previous version of the file.
How to uncommitted the changes/ undo commit changes / Resetting changes
(NOTE: The URL change every time)
- How to push your changes on a particular code base or an existing repository
6. Git CLI π»
There are a lot of different ways to use Git. There are the original command-line tools, and there are many graphical user interfaces of varying capabilities. The command line is the only place you can run all Git commandsβββmost of the GUIs implement only a partial subset of Git functionality for simplicity. If you know how to run the command-line version, you can probably also figure out how to run the GUI version, while the opposite is not necessarily true. Also, while your choice of graphical client is a matter of personal taste, all users will have the command-line tools installed and available.
7. Installation π
You need to install Git on your computer before you start using it. You can install Git on Windows, Linux, and macOS operating systems.
Mac
To install Git on macOS, visit the website git-scm.com/download/mac and follow the easy steps.
Linux
The easiest way to install Git on Linux is by using the
apt
.
sudo apt install git-all
For RPM-based distributions, you can use the dnf
.
sudo dnf install git-all
Windows
You can find the official Git builds on the Git website. Download the installer from git-scm.com/download/win and start the installation.
8. References π
π© https://git-scm.com/
π© https://youtu.be/apGV9Kg7ics
π© https://youtu.be/RGOj5yH7evk
π© https://youtu.be/pZwFizZUbzU
π© https://youtu.be/404FBKnGb2M
That's all for this blog, I hope you will learn something new. And feel free to share your thoughts and feedback, Thanks for reading.
Feel free to reach out to me π
Twitter π±
LinkedIn π±
Github π±