32
loading...
This website collects cookies to deliver better user experience
Git
is one of the most used tools in the tech industry as it efficiently solves the version control issue. Without git
, even a simple project might end up looking like this:Git
helps to keep track of different versions of a single code base by tracking all changes. With git
, even a complex project (Material UI) ends up looking condensed like this:git
is a really useful tool, everyone (including me) while starting, has a lot of issues wrapping their heads around how it works. This article aims at demystifying git
for you.git
you will need to install it. You can download and install git
from git's website. Make sure you add git
to Path
in case you are using it on Windows. In Linux, you can directly install it from the terminal using:sudo apt-get install git
git
was installed properly execute the command:git --version
Git
works by storing a snapshot of the entire repository at any given point of time when you commit changes (a commit can be considered to be an equivalent of a save). So whenever you wish, you can go back to any previous commits and make modifications.git
, you would require a repository. To initialize a repository use:git init
git add <file 01 path> <file 02 path> <...>
git add .
git commit -m "<small description of the change (for ease of understanding)>"
git log
git
also has two solutions for that:git reset --soft HEAD~1
git reset <reset types> HEAD~<number of commits to undo>
git revert 8a11c5095f2dcd70b0bc8c66061a1368558a3abf
git revert <commit hash>
.git
features which are a bit harder to grasp.git
, you definitely would like to keep track of several copies of the same project. Git
has you covered! There is a feature to create branches of the code to scope modifications like feature additions, bug fixes, etc to only one branch, which may later be merged with other branches. git checkout -b <new branch name>
git checkout <branch name>
git merge <update source branch name>
git
doesn't know which change to keep and which to discard. So git
creates a conflict message for manual review.git
and how to add it to a project. Now you have this skill in your arsenal and would be able to use it in your projects to maximize your productivity :)git
for remote repositories hosted on sites like GitHub.