Hey Guys! This is Shivam.
Today, we are going to discuss Open Source. We will learn:
- What is an Open Source?
- Basic Git Commands you need to start.
- How we can contribute to an Open-Source?
- Example to Contribute to an Open-Source.
- Which community you should join to get Opportunities?
Let's start with a definition of an Open-Source.
What is an Open-Source or GitHub?
In simple terms, GitHub is a code hosting platform where you can upload your codes like you upload videos or photos on Social Media apps. If you and your friend want to work on the same project but you are in different places then at that time Github comes into the picture and, we can share our code.
Now, one thing you always keep in mind before getting started with an Open-Source or GitHub is that "GitHub is for Collaborating not for a Competition". So, if you want to collaborate with people, learn in public, help others by contributing, and want to grab opportunities then, you can join GitHub and start your journey.
Basic Git Commands
Now to start contributing to a project we need to learn about "Git Commands". Now here I am not going to deep dive into Git Commands because today we are focusing on the contribution part. But I will tell you some of the basic commands from which you can start.
Now, let's see the basic commands of Git to contribute to an Open Source.
- Git Status: The git status command displays the state of the working directory and the staging area
git status
- Git Commit: The git commit command captures a snapshot of the project's currently staged changes.
git commit -m "Write about what you change in the project"
- Git Push: The git push command is used to upload local repository content to a remote repository.
git push
- Git Clone: git clone is a Git command line utility that is used to target an existing repository and create a clone or copy of the target repository
git clone "ssh key"
-- will talk about the ssh key during the example
Here are some of the basic commands you should know about during your contribution. But apart from these, there are more git commands. You can check here
Now let's start with an example to understand contribution in GitHub.
How we can contribute to an Open-Source?
To contribute to a Project you should have a GitHub account. If you have not yet, you can create it here.
Now, after creating an account you can find projects based on your skills for contribution. For this Tutorial, I choose the project named HactoberFest. I recommend everyone new to GitHub contribute to this Repository.
Now, for this contribution I am going to use "VS Code" you can choose any code editor.
- Let's start with a contribution. Click here and you will land on this pageπ
- Now click on the Fork(Fork is like a copy of that project) button to Fork this Repository.π
- Now this window will appear, Click on "Create Fork" to fork the Repository.
Now you will see that the same Hacktoberfest repository is appearing in your account now(You can see your name in the left corner). And below your name, it is written that Forked from EddiehubCommunity, which means that we made a copy of EddieHubCommunity's project. Now you can edit this project.
- Now click on the code button which appears in green color.
- And the drop-down will appear. Click on the "SSH" and copy this "SSH key". ssh key helps you to link your remote repository with your local repository. Now if you don't have an ssh key you can make a new one by following this article or for now you can start by clicking GitHub CLI or HTTPS. Click on any one of three and copy that key.
- Now after copying, go to your code editor and a new fresh folder and open up the terminal in it. Now we are going to clone that repository by running the below commandπ
The above command looks like this π in the terminal.git clone https://github.com/YOUR_GITHUB_USERNAME/hacktoberfest-practice.git
Now, we are switching to this repository's folder for that we run the cd command.
cd folder name
You can do like this π here our folder name is hacktoberfest-practice
Now we are in this folder, now we can start contributing. Before contributing to any project you should read that project's Readme file.
Now for this contribution we go to the readme file. You can see that readme file which appears on the left side.
Note- Every Project has different-different contribution guidelines. So, be sure you check out that project's readme file before starting to contribute to it.
Now click on the readme file.
- Now, after clicking on the readme file you will see this screen π. Now if you scroll down a little bit you will see, that there are many names present in it. These are the names that are added by many different contributors. Now, we will be adding our name to it and being the contributor
- So, now scroll down the screen as per your name's first letter. My name starts with the letter S so, I will scroll till S and write my name.
Write this command where you want to add your name.
[Full Name](https://github.com/your-username)
-- don't do any typo mistakes.
- Now, after writing your name check the status of the file, by typing this π command in the terminal.
git status
- Here you will see the file name which you just changed in red color.π
Here it is not staged yet so, we will now stage this file by writing the commandπ in the terminal.
git add filename
or
git add.
- Now after staging it again run the status command. Now, at this time you'll see that it is showing with green color.
- Now we will commit this file. In simple terms, commit means, leaving a note to that file, which helps, later on, to understand what change you do on that file. So, for commit, run this command. π
git commit -m "Any message you want to add"
This will look like thisπ
And, when you press enter you will see something like thisπ. Here it will show you how many lines you changed or deleted.
- Now we will push our local code to the remote repository, to do that we will run this π
git push
It will look like this π
Now go to your GitHub account and click on the Hacktoberfest repository. There you'll see the all files. Now click on the Pull Request where you'll see this π screen.
- Click on the New Pull Request option and, you'll see this screen π
- Now click on the "Create Pull Request" option. Now, this π screen will appear. Write your name in the text box as you can see in the image below I write mine(Don't do any other changes).
- Click on the "Create Pull Request" button and you will see this πscreen with your account name.
Here you created your "Pull Request(PR)". After some time there will be a message which gonna be look like thisπ. It means your first Open-Source Contribution is done.
If all checks don't pass it means, you have done something wrong and you have to do some checks where you edit the code.
Conclusion
So, this is the contribution process of GitHub. You should have to contribute daily, Just give 1 hour a day to open source, and then, the response will be going to surprise you.
Things to Remember
- Don't hesitate to ask questions
- Don't think you don't have skills. A person with 0 skills can also contribute
- Join Good-Good communities for more improvement.
Community You Can Join
There are many good communities on GitHub you can join any of them it's up to you. Here are the 2 communities which will help you to understand more about OpenSource.
Thank You
Hope you'll learn something from this blog. If you found something good don't forget to give your feedback.
You can join me here π for more daily updates.