Getting Started With Basics Of Git Commands And How To Start Contributing.…
Robot Jelly
Posted on May 5, 2020
Nowadays if you look around you [i mean online…!!] you will get to know that many organizations and many other online hackathons are more focusing on these GitHub contributions by the contributors around the world.
I have attended several sessions for beginners where I was told with the ways to start contributing to various open-source projects. Now, from being a participant in various online competitions like hacktoberfest, GSSOC — Girslscript Summer Of code to being a mentor in Google Code-in, I got to learn so much and now, I feel like I have some sort of experience which I can share with my fellow ones to start their journey as well in open source.
After, interacting with so many newbies who want to take my advice to start their journey in open-source as well, I finally thought to write this new article for them. Although I would not go too deep in its theoretical part [for that many other tutorials and articles are already there] as in this article my intention is to help you start contributions without much efforts….
Now, What exactly are git and Github? :
Github is a remote code-hosting platform for various Git repositories where in your files are hosted which you can further share with anyone..
Git is a distributed version control system for tracking those files which you are hosting on Github . Basically, In Git there are some commands which you have to write in your git bash terminal [similar to your windows command prompt] and with the help of these commands you can track the versions of your code in your local machine . However, if you want a remote backup of your code or want to share it with others for any sort of collaboration then you can push it to Github.
Now, If you are not satisfied with the above definitions and want to know more about version control, Git or Github then can you refer to this article !!
Now to start writing git commands you need to set up or go through the installation process of git for which you can follow this article
Now to start writing git commands you need to set up or go through the installation process of git for which you can follow this article
For setting up the Github account you can follow this article
Now we are ready with everything so, let's start your journey …..
Note:- [Assuming that you have already installed everything [that too without any error]]
Now you can start to choose to which project you want to contribute .
So, to make things easier for you lets take an example, let's say you found one project/repo named TestGit and you want to add/edit let's say it’s README file…so, to add your file/edit this existing one into your repo you need to follow the following steps :
Step-0 : To start your contribution, you first need to create an issue or you use the existing issue in the parent repo [of any organization] by commenting/asking on that issue created by others. In my case, I am just editing the existing READme file So, for that, I will create an issue in the parent repo, describing what I want to add in that repo [as a contributor] and then the maintainer of that repo will assign me that issue :
First Go to Issues [of organization's/parent/remote repo] then click that green button of New Issue :
Next, fill up that issue template first about why you are creating or describe your issue and then click Submit Issue
[Note that some repos have specific templates so, you need to follow that only. Here, there is no such template] :
---------------------------Fig: Submitting New Issue--------------------------
Step-1 : Once you are assigned for that issue [by maintainer] then next, you need to fork that repo into your repo [this will create a new repo in your Github and will indicate this as a forked one] :
Go to Fork button at the top right corner of that repo :
-----------------------------Fig: Forking the repo---------------------------
Then, you will see that fork sign at the top left corner [that is a forked repo] and then you need to go to clone button of your forked repo :
----------------------------Fig: Forked Repo----------------------------------
Step-2 : Then, Go to Clone or Download Button [green one] then copy that clone link.
Step-3 : Open your Git Bash, then go to your desktop [or any other folder where you want to place your downloaded/cloned file] by using the following command :
cd desktop
Step-4 : Then, by using the following command in your git bash, you will be able to clone that file locally :
git clone "link you copied paste here"
-------------------------Fig: I have cloned in my desktop----------------------
Step-5 : Then, go into that folder which you cloned by cd command and then add that code or any changes you want to do in that file with the help of any editor [In my case, I am just making a small change in readme file by using atom editor].
Step-6 : Now, it is always good to make a new branch every time if you are contributing to any open source project as this will not mess up the things you are putting up in the remote repo (i.e. repo of that organization which is parent repo) :
git checkout -b "your_branch_name"
----------------Fig: Creating a new branch to add changes----------------------
Note: Don’t use space while naming a new branch.
Step-7 : Now, to see what’s going on in your working directory, run the following command :
git status
this command will show you all the files that you have modified as an untracked/not staged for commit :
--------------------Fig: Shows the file which I modified-----------------------
Step-8 : Now, next you need to add all the modified files into the Staging area [wherein you collect all the changes you want to put into repo] by using the following command :
git add "modified file"
Step-9 : Next, you need to commit all your added files with the appropriate message. this will be added into your local repository [the forked repo] :
git commit -m "any meaningful message"
Step-10 : Next, you need to add your modified files [which you committed] from your forked/local repo to the remote repo [the original/parent repo] so, for that you need to Push them :
git push origin "your branch name"
----------------------Fig : Pushed Modified File Into Repo---------------------
Step-11 : It’s almost done, next you will see the message on the remote repo with the green button “Compare & Pull Request”. You need to click that and then this opens a new PR where you need to write the description with the reference to that issue which you created [fixes: #1 — in my case] and then click that green button at the bottom of that saying “Create a pull request” that’s it !! :
------------*Fig: Pushed Branches are Shown in your repo/forked repo------------
------------------------Fig: Creating New PR-----------------------------------
Yay!! you made your first contribution in the open-source world. Cheers…
This was just a part of my original article to help you start your open source contribution. It's important to improve your pushed PRs and to learn that & more tips & tricks read my full article here:-
Posted on May 5, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.