Have you ever wondered what git is and how it can be used to contribute to open source?
In this article I will highlight few of the frequently used git commands and terms that are used while contributing to open source.
Open source refers to something people can modify and share because its design is publicly accessible - Opensource.com
git is a distributed version control system for tracking changes in source code during software development..... it can be used to track changes in any set of files -Wikipedia website
Contributing to open source is one of the many catalyst for growth in the tech space. It provides value to the community and individual.
If you started using git recently or if you haven't used git before, then this article is for you.
I recently started contributing to open source and I must tell you it is something you should start doing if you haven't started.
And there are some git terms and commands that I use always so I decided to write about them, more like keeping a note and so it can help someone out....
Remote in git
Remote means a repo that is hosted online apart from your computer. It might be on GitHub, GitLab, Perforce, Beanstalk
Local in git
This is the copy of a repo that is on your computer. It can also be a code file that hasn't been uploaded to the remote site.
git checkout -b
This command creates a new branch and switches to it.
The syntax is git checkout -b [branch-name]
It comes in handy because it eliminates the option of using two git commands to create a branch and switch to the new branch
git pull
This command updates the copy of your local branch that has been forked previously so it is up to date with the remote branch. It is advised to always do git pull
before git push
so you don't get merge conflict because it updates the branch with the current state of the branch
git push
This used to update the branch that you are currently on to the remote. It pushes all committed changes to the remote branch that is checked out. The syntax is
git push -u origin [branch]
it creates a new branch if the branch you are pushing doesn't exist on your remote repo.
Conclusion
There are a lot of git terms and commands out there. Some of them might be confusing but when you use them constantly, you will get to understand them more.
Credits
- Wikipedia website
- opensource.com