As a beginner in programming or IT you must have wondered what is Git , what is it used for . You mush have come across complicated definitions such as :
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
After reading that definition you must have thought “What does that even mean” , well at least that was my reaction when i was a beginner. So the million dollar question is “What is Git” .
Now before i explain it keep in mind that i may not use the exact terms a IT professional would use to explain git.I will try to explain it in simpler terms.
What is Git? Git is a application or a kind of Software that is used to keep track of any changes that occur in a specific folder.This helps in the process of software development or coding when there a many people working on a single project.It wouldn’t make sense to write a message or an email just so that you could notify the project manager that you added a line of code in a branch of that project , obviously you need a system that does it for you automatically.Along with this , git does provide many other useful features like reverting back to previous versions , which in simple term means that if you made a change in the code and finalized it but now for some reason you don’t want that anymore you can go back to the previous version or undo that change. Pretty cool , isn’t it ! Now there are many cloud platforms which make use of this technology (git) so that developers from all over the world can work on different projects.Few of the well known are GitHub , GitLab , Bitbucket. Git has its gui and cli versions available across all major platforms for free and opensource use.Most of the professionals prefer the command line versions as they are easier and straightforward to use.
Git terms :
git: an open source, distributed version-control system
GitHub: a platform for hosting and collaborating on Git repositories
commit: a Git object, a snapshot of your entire repository compressed into a SHA
branch: a lightweight movable pointer to a commit
clone: a local version of a repository, including all commits and branches remote: a common repository on GitHub that all team member use to exchange their changes
fork: a copy of a repository on GitHub owned by a different user
pull request: a place to compare and discuss the differences introduced on a branch with reviews, comments, integrated tests, and more
HEAD: representing your current working directory, the HEAD pointer can be moved to different branches, tags, or commits when using git checkout
Git Basic Commands : The folders which make use of git are called Git repositories .Any new changes made to the files within that folders are called commits.
Create repositories : When starting out with a new repository, you only need to do it once; either locally, then push to GitHub, or by cloning an existing repository.
$ git init : Turn an existing directory into a git repository
$ git clone [url] : Clone (download) a repository that already exists on GitHub, including all of the files, branches, and commits
Git also contains a system of branches which comes in handy on large projects where we don’t want to make changes directly to the production line.There is a main or master branch in git.You can create secondary branches for work and then merge the finalized features to the main branch.
Branches : Branches are an important part of working with Git. Any commits you make will be made on the branch you’re currently “checked out” to. Use git status to see which branch that is.
$ git branch [branch-name] : Creates a new branch
$ git checkout [branch-name] : Switches to the specified branch and updates the working directory
$ git merge [branch] : Combines the specified branch’s history into the current branch. This is usually done in pull requests, but is an important Git operation
$ git branch -d [branch-name] : Deletes the specified branch
Synchronize changes : Synchronize your local repository with the remote repository on GitHub.com
$ git fetch : Downloads all history from the remote tracking branches
$ git merge : Combines remote tracking branch into current local branch
$ git push : Uploads all local branch commits to GitHub
$ git pull : Updates your current local working branch with all new commits from the corresponding remote branch on GitHub. git pull is a combination of git fetch and git merge
Conclusion : These are some basic commands that are used in Git.If you are a beginner in programming you should definitely make a GitHub profile or any platform of you choice and try to contribute to open source projects.This can help you build up your Resume as well ! If you loved this story then follow me on Twitter.