Git is a distributed version control tool that facilitates monitoring changes made to your code over time. Git makes it simple to track changes to your codebase and collaborate on projects with others. It was authored by Linus Torvalds in 2005 for developing the Linux Kernel, with other kernel developers contributing to its initial development.
It enables us to track changes in our code and collaborate with others, by working on a different part of a codebase. When we say distributed, we may think we have code on two locations, remote server and locally, but the story is a bit more complex.
Git is a free and open-source version control system used to track changes in software projects. It is used by developers to keep track of different versions of their code, and to collaborate with other developers on the same project.
Git works by storing a history of all the changes made to a project. This history is called a commit history. Each commit in the history is a snapshot of the project at a particular point in time.
Developers can use Git to view previous versions of their project, to revert to a previous version, or to merge changes from one branch to another.
Git can be used with any programming language or software project. It is a powerful tool that can help developers to track changes to their code and to collaborate with other developers.
Here are some of the benefits of using Git:
Version Control:
Git can help you keep track of changes to your code, so that you can easily revert to a previous version if you need to.
Collaboration:
Git can help you collaborate with other developers on the same project. You can merge changes from one branch to another, and you can view previous versions of the project.
Extensibility:
Git is a powerful tool that can be extended with plugins and scripts. This means that you can customize it to fit your needs.
If you are looking for a version control system for your software project, then Git is a great option. It is a powerful tool that can help you to track changes to your code and to collaborate with other developers.
Git has three storages locally:
1. Working Directory - This is where you work and your files live (also called "untracked"). All file changes here will be marked; if not saved to GIT, you will lose them. The reason is that GIT is not aware of those files.
2. Staging Area - When you save your changes with git add, GIT will start tracking and saving your changes with files. These changes are stored in the .git directory. Then, files are moved from the Working Directory to the Staging Area. Still, if you change these files, GIT will not know about them; you need to tell GIT to notice those changes.
3. Local Repository - It is the area where everything is saved (commits) in the .git directory. When you want to move your files from the Staging Area to the Local Repository, you can use the git commit command. After this, your Staging area will be empty. If you want to see what is in the Local repository, try git log.
Some basic GIT Commands are:
git init - Create a new git repo in the directory
git branch - Create a new local branch
git checkout - Switch branches
git add - Add a new file to your staging area
git commit - Adds staged changes to your local repository
git pull - Pull code from your remote repo to your local directory
git push - Push local repository changes to your remote repo
git status - Show which files are being tracked (and untracked)
git diff - See the actual difference in code between your Working Directory and your Staging Area
Along with GIT commands, you can try and use some popular GIT Tools: GitHub Desktop, SourceTree, TortoiseGit, Git Extensions, GitKraken, SmartGit, Tower, etc.
