Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Basic Git Commands for Open Source Contribution

In my last post I discussed about how one can get started with contribution to Open Source. You need to know some Basic Git Commands to work flawlessly with open source projects.

Let’s discuss them one by one by taking an example project, Titanic –

  1. Set up Git as given here. This is a pretty quick tutorial on setting up Git.
  2. You would need to fork the repository on which you want to work, in this case it is Titanic. Forking would bring that project’s code to our workspace and hence allows us to make changes to it. Login to Github, go to the repository you want to fork and click on “Fork” on the upper right hand side of the page. Once forked, you can see the repository in your Github profile and below that you would see “forked from <orginal_repository>”.
  3. Now we need to copy this code to our machine so that we can make changes to it. For that we would “clone” the forked repository. To clone the repository to your machine, run the following in any directory in your machine –
    git clone https://github.com/theharshest/titanic
  4. We have whole source code of this project now. This is the time to make changes to the file, i.e. we fix the bug in the concerned file. After you are done making changes to the file/files, we need to “stage” the files. For that, do the following from the repository directory –
    git add --all
  5. At any point of time you can run git status to see the status of our work in git. Now, we need to “commit” the changes we just made using –
    git commit -m "Adding a bugfix"
  6. After committing the changes, we would push the changes to our forked Github repository. To do that, run –
    git push origin master
  7. Now our forked repository has the changes, but the main repository from where we forked our repository doesn’t know anything about the changes we made. We, of course, can’t make changes to it directly, as we are not the owner of the repository. We would request the owner of the repository to look at the changes we made and if he feels the bugfix we made is correct, he can approve and merge those changes to the main repository. To achieve this, we would do something called as “pull request” –
    1. Go to your forked repository and in the right sidebar, click on “Pull Requests”.
    2. Now click on “New Pull Request”, provide a description and create the pull request.
  8. After this, the author of original repository would see your pull request and if he thinks that you’ve made the correct changes, he would go ahead and merge and close the pull request. Now, the main repository has the changes that you’ve made.

This is a very high level talk on Git which doesn’t go into the meaning of commands. I would suggest you to watch the following screencast to get hold of Git basics –

Share and Enjoy

• Facebook • Twitter • Delicious • LinkedIn • StumbleUpon • Add to favorites • Email • RSS

The post Basic Git Commands for Open Source Contribution appeared first on Harsh Tech Talk.



This post first appeared on Harsh Tech Talk, please read the originial post: here

Share the post

Basic Git Commands for Open Source Contribution

×

Subscribe to Harsh Tech Talk

Get updates delivered right to your inbox!

Thank you for your subscription

×