github

Search GH for strings within specific file names

Snippet

Github has a LOT of code repositories. Sometimes, you want to search for how someone does a task in a specific, well-known file name for a project. For example, all Rails apps have a Gemfile, maybe you want to find a version of a gem used in a Gemfile.

Combine Github search filters to find exactly what you need.

# search for the word "command" in all files named "app.yml"
command in:file filename:app.yml

Sync a github forked repo

Snippet

Forking a github repo inherently takes it out of the originating repo flow. Sync it back this way.

# check your remotes
git remote -v
 
# origin  git@github.com:YOUR_USERNAME/YOUR_FORK.git (fetch)
# origin  git@github.com:YOUR_USERNAME/YOUR_FORK.git (push)
 
# add the remote
 
git remote add upstream git@github.com:ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
 
# note, the original docs assume you don't have a github account set up properly.  If not, do this one:
# git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
 
# and confirm
 
git remote -v
 
# might look like this:
# origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (fetch)
# origin    https://github.com/YOUR_USERNAME/YOUR_FORK.git (push)
# upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (fetch)
# upstream  https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git (push)
 
# get the changes from the originating repo
 
git fetch upstream
 
# check out the master branch to sync to
 
git checkout master
 
# and sync away
 
git merge upstream/master
 
# then back to your branch and continue
 
git co this-is-my-branch
git rebase master
git push --force origin this-is-my-branch
 
# etc.