git

Checking Out Pull Requests with Stash and Github

The day Jeremy Edgell, a co-worker at Classic, mentioned it was possible to checkout pull requests, I knew that this trick would greatly increase my code review efficiency. Jeremy's solution involved adding an additional reference to the pull request location in an individual git repo's .git/config file. You can see a similar example to Jeremy's Stash solution in this gist.

Checking%20out%20a%20Github%20pull%20request Checking out a Github pull request (Note: The git alias, gpr-origin, indicates the remote to reference. I have one setup for origin and upstream.)

Blog Category: 

A Good Case for Git Interactive Rebasing

One thing that drives me crazy is a messy git log full of unimportant commits. While I subscribe to the commit often philosophy during development, it does lead to commits which have no historical significance to upstream project branches. Who needs a git history full of commit messages like corrected spelling and fixed a php notice. These commits are helpful during active development, but they just clutter up git history if pushed to an upstream repository. It doesn't have to be this way!

Blog Category: 

How to Export a Single File Form a Git Revision to the Local Working Copy

I needed to test an older version of a file in a web app, but didn't want to checkout the entire codebase. The method below allowed me to easily checkout an older version of the file using the commit hash that I knew had the correct file. Other git object references such as tags, branches, and commits from HEAD can be used instead of the commit hash (full or short SHA). See details here.

$ git show [commit-hash]:/path/to/file/file.txt > file.txt

Blog Category: 

Excluding files from git

Three very useful ways to eclude files and folders from git:

  1. Add a .gitignore file to your home directory and add files and folders you want all of your local git repos to ignore. For example: My .gitignore file.

  2. Add a .gitignore file to your local repo, stage, and commit the file as part of your codebase. This is very handy if you want to share a common set of files/folders to ignore with others working with the same upstream repo.

  3. Add files and folders to .git/info/exclude. The exclude file is found in every git repo and allows you to set ignore rules that will only work for your local repo. It will not get sent upstream during a push.

Checkout this excellent github help page for more details and examples!

Blog Category: