Git
Version Control System. What is it and it's History?
What is it?
"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" - Git website
Free and open-source
It is a version control system
software for tracking changes in any set of files
usually used for coordinating work among programmers collaboratively developing source code during software development.
Speed and data integrity are important aspects of Git
It supports distributed, non-linear workflows (many parallel branches running on different systems)
What is the need to use it?
Git is the most commonly used version control system.
Git tracks the changes you make to files, so you have a record of what has been done, and you can revert to specific versions should you ever need to.
Git makes collaboration easier, allowing changes by multiple people to be merged into one source.
Hence, a collaboration between multiple developers working on the same project is much easier with Git. If there is some problem with the deployment, we can always revert back to the previous version
Few Important Commands
Know the terms:
Repository: A repository contains all of the project files (including documentation), and stores each file's revision history
Branch: A branch is a version of the repository that diverges from the main working project. It is an essential feature available in most modern version control systems
For more, refer to the following link
For account setup and creating a repository, in my opinion, it is better to use the git UI (git website) directly. For other functionalities, all the important commands are listed below, For more commands, refer to the following link
# To clone complete repository into your local
git clone <repository link>
# When you want to commit your changes to any branch, you need to follow three steps
# add, commit and push changes
# To add all the changes to done in current branch
git add --all
# To get the extra changes you have made in the branch
git diff
# To get current branch, and if anything is there to commit
git status
# To commit change
git commit -m '<comment related to changes you are committing, be specific>'
# It will remove all changes and reset the branch to last commit
git reset --hard
# To commit changes to the branch
git push
# To pull the latest branch
git pull
# To create a new branch named <branch name>, it will have all content of
# working branch, please note: visible only when add, commit, and push is done
git branch <branch name>
# To change the branch to <branch name>
git checkout <branch name>
# Merge adds changes of <branch name> to current working branch
# In case of issues, you will have to resolve before merging
git merge <branch name>
# git stash, it is used when we are working on some branch, but due to some
# reasons want to change the branch without committing the changes in current
# branch, we stash changes and switch to other branch
git stash save # to stash the changes in a branch for later use
git stash pop # to start working on last stashed branch (changes in a branch)
git stash list # to list all the saved stash in the branch
git stash drop # to drop last stashed changes from the branch
Where should I read more about it?
Working with git is more about usage. Giving too much time in learning Git does not make sense to me. It is an add-on to productivity, efficiency, and project management. Hands-on should be the way to go. For an overview, here are the links:
Last updated
Was this helpful?