Here, we are again with another beginner friendly blog. In this blog we will learn about one of the most popular version control tool, yes you guessed it right. I am talking about git.
In the blog we shall learn about -
Let's start with the Version Control.
Version Control is a system which helps you to keep a track of all the changes you made in files or codes by keeping the track of each version you build so that you can rollback to previous version if needed. In layman language, it helps you to organize the things in a better way.
Version Control provides an efficient way to manage your codes or files, but if you are thinking why exactly do we need it, let me give you an example.
Let's assume a scenario, today most of the companies are adopting Work From Home culture. Let's say we have 10 developers working on a product, building features for it from their home, so now how will they organize their code. Here comes the role of Version Control tools like git.
Still confused 🤔!
Let me give you another use-case. For example, you have build an application and deployed it. Everything works fine in the current version. Maybe you have added few new features and again deployed it but this time the application breaks. Now again comes the role of Version Control. By using version control tools such as git you can easily rollback to the previous version of your code.
This is how Version Control tools acts as a
Savior for almost every organization.
In the above section we learned about Version Control and its need. Now let's understand what exactly is Git and why it is so popular in the industry. Git is a version control system which is adopted by many companies and OSS users to maintain their code in local as well as remote repositories. The term repository here refers to storage container where project files are being stored and it can be any repository, be it GitHub, GitLab or Bitbucket. It is mostly used in the Software Development Industry to keep a track of changes made in code and also helps to increase the speed of development by providing a better support for distributed/collaborative development environment.
Now let's start with the open source contributions and learn about some of the most useful git commands which are used commonly.
[Note: The blog is specific for open source contributions so we will discuss only those commands which are related to it]
Step-2: Now clone the forked repo in your system using the following command.
RemoteUrl with the URL of Repository you want to clone
git clone RemoteUrl
Step-3: Create a new branch for adding your changes. Use the below command, it will create a new branch and checkout into the newly created branch.
git checkout -b NewBranchName
To verify your current branch you can use
git status command. It will give you all necessary details of git initialized repository.
Step-4: Now make the changes which you want as your contributions. After the changes has been done, you need to add those changes to git. Use the following command to add those changes.
git add ChangedFileName
Also you can add all the changes by using period(.) If you have changed multiple files this can be really useful. Move to the root directory of the project and then run the following command.
git add .
Step-5: Now commit the changes you made with a commit message. The message should be relevant to the change you did as it would be helpful for tracing.
For example, I made changes in README.md file so the command would be something like this -
git commit -m "Added discord link in README"
[Note: It is not mandatory, but as a best practice you should add relevant commit messages]
Step-6: Now we need to push the changes we did. We have to push in the same branch in which we are working. Use the below command to push your change -
git push -u origin NewBranchName
Congratulations 🎉! Now we are ready to raise our first Pull Request and make our first open source contribution.
Tada! We just did our first open source contribution 🎊.
Now we understood how we can start our open source contributions. If you want to do some quality contributions and be the part of biggest opensource fest, yes I am talking about Hacktoberfest, feel free to check out this repository and unlock the cool giveaways along with the Hacktoberfest swags.
Yes! You read it right. You will get some awesome giveaways from Devtron for contributing on their repositories apart from the hacktoberfest swags. Everyone at any level is invited to contribute and take the giveaways. Please refer the below repository for better understanding of the swags and contributions guidelines.
Источник: dev.togithub hacktoberfest opensource beginners