Github started life as hosting Git repositories.

Github has an advanced search mode, here are some useful commands.

TermDescription
repo:gohugio/hugoSearch within a repository
filename:note.htmlSearch for a specific filename

Submitting Pull Requests to Other Repos

If you want to submit a pull request to a repo that you don’t have write access to. You can follow these steps.

For this example, lets use the following repo names.

  • source repo: github.com/sally/useful-lib.git
  • your forked copy: github.com/me/useful-lib.git

1. Fork the repo

In the github UI, click the fork button on sally’s useful-lib.

2. Clone your copy of the repo

$ git clone git@github.com:me/useful-lib.git

3. Create your pull request

Create a working branch

$ git checkout -b myfix

Make your code changes, commit and push your branch to your repo

$ git commit -am "My new feature"
$ git push -u origin myfix

Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 4 threads
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 1.39 KiB | 1.39 MiB/s, done.
Total 5 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
remote: 
remote: Create a pull request for 'github' on GitHub by visiting:
remote:      https://github.com/me/useful-lib/pull/new/myfix
remote: 
To github.com:me/useful-lib.git
 * [new branch]      myfix -> myfix
Branch 'myfix' set up to track remote branch 'myfix' from 'origin'.

On your github page, create a pull request

If changes are requested to your code, make more changes on your local branch and push them to the server. They will be incorporated into the pull request.

4. Merging upstream changes

After your pull request is merged into master on the source repo. You may want to keep your forked copy up to date.

$ git remote -v

origin  git@github.com:me/useful-lib.git (fetch)
origin  git@github.com:me/useful-lib.git (push)


$ git remote add upstream https://github.com/sally/useful-lib.git
$ git remote -v

origin  git@github.com:me/useful-lib.git (fetch)
origin  git@github.com:me/useful-lib.git (push)
upstream  https://github.com/sally/useful-lib.git (fetch)
upstream  https://github.com/sally/useful-lib.git (push)

4.2 Merge upstream changes

$ git checkout master
$ git fetch upstream

remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (1/1), 679 bytes | 679.00 KiB/s, done.
From https://github.com/sally/useful-lib


$ git merge upstream/master

$ git push

As future changes happen to the upstream, you only need to run step 4.2 again to update your copy.

Resources