Git How to’s 

git checkout -b refactor

Courtesy of git animals

This post intends to be a collection of useful commands and explanations of common tasks involving this awesome tool, and how to contribute to Open-source software using it. Perhaps it comes in handy to someone else too.

Find forgotten TODOs and FIXMEs

grep -RIn TODO target_directory/*

Forking and contributing with Github

Go to project repository page and click on ‘Fork’ button. After that, clone it to your local machine:

git clone **your ssh/git url**

Add a upstream branch (helps to get the updates from the original project repository):

git remote add --track master upstream git://github.com/upstreamname/projectname.git

Create a new branch to accommodate your work (help the pull request workflow):

git checkout -b name-of-your-branch

Get updates from the original repository:

git fetch upstream
git merge upstream/master

Submitting a Pull Request:

git push origin name-of-your-branch

Go to your forked repository page on Github, and change the branch to the one recently pushed.

Next, click on the button that says ‘Pull Request’. Describe it the best as you can, then submit.

Whenever you commit and push more things to that branch of your code, they will be included in that pull request until it is closed.

Github <3 Git

For those who doesn’t have a Github account yet, follow this link to create one.setuptocat - github and git

And, here’s how to setup Git under Ubuntu:

  sudo apt-get update && sudo apt-get upgrade
  sudo apt-get install git-core git-doc

Next, configure Github:

  git config --global user.name <git-username>
  git config --global user.email <git-email-address>
  ssh-keygen -t rsa -C <git-email-address>

The key that you just generated must be added to your Github account. If you don’t know how to do this, click here.

References

http://ivanzuzak.info/2012/03/03/todos-ideas-for-contributing-to-open-source-projects.html

http://robots.thoughtbot.com/post/5133345960/keeping-a-git-fork-updated

http://gun.io/blog/how-to-github-fork-branch-and-pull-request/

https://help.github.com/articles/fork-a-repo

http://anders.janmyr.com/2012/01/finding-with-git.html

http://eagain.net/articles/git-for-computer-scientists/