Oh, shit, git!

git

Git is hard: screwing up is easy, and figuring out how to fix your mistakes is fucking impossible. […] Here are some bad situations I’ve gotten myself into, and how I eventually got myself out of them in plain english*.

Provides solutions (commands) to scenarios such as “Oh shit, I accidentally committed something to master that should have been on a brand new branch!”.

Oh, shit, git! →

A bunch of handy Git aliases

git

Tim Pettersen, developer at Atlassian (BitBucket & JIRA):

Git has a strong commitment to backwards compatibility: many powerful features are hidden behind options rather than exposed as default behaviour. Fortunately Git also supports aliases, so you can create your own commands that do all manner of Git magic. Here’s a selection of the more useful (or at least entertaining) aliases defined in my .gitconfig.

That git commend will come in handy 🙂

Lesser known Git commands →

(via Freek)

lint-staged: Lint JS and CSS files staged by Git

lint-staged

Running a lint process on a whole project is slow and linting results can be irrelevant. Ultimately you want to lint only files that are staged/will be committed.

This project contains a script that will run arbitary npm tasks against staged files, filtered by a spicified glob pattern.

lint-staged introductory blogpost: Make Linting Great Again →
lint-staged (GitHub) →

GitUp

Work quickly, safely, and without headaches. The Git interface you’ve been missing all your life has finally arrived.

Really interesting Git client: the timeline is the interface. Just right click any commit an select what you want to do with it: edit the message, remove it, squash it, split it, etc.

GitUp →

GitBook: Build beautiful interactive books using Git and Markdown

gitbook

Write your books and courses using Markdown, GitBook will convert it to a complete static website.

Installable using npm. A companion app (pictured below) to create your books – in case you want a live preview along your edits – is also available.

gitbook

Building the book to a PDF/eBook is also possible … strongly considering to rewrite my course materials, already freely available online.

GitBook: Build beautiful interactive books using GitHub/Git and Markdown →
Example Book: Learn Markdown →

PHPloy – Git FTP Deployment

; This is a sample deploy.ini file.
; You can specify as many servers as you need
; and use whichever configuration way you like.

[staging]
user = example
pass = password
host = staging-example.com
path = /path/to/installation
port = 21
passive = true

[production]
user = example
pass = password
host = production-example.com
path = /path/to/installation
port = 21
passive = true

; If that seemed too long for you, you can use quickmode instead:
[quickmode]
    staging = ftp://example:password@staging-example.com:21/path/to/installation
    production = ftp://example:password@production-example.com:21/path/to/installation

PHPloy is a little PHP script that allows you to deploy files through FTP to a server. It makes use of Git to know which files it should upload and which one it should delete. PHPloy supports deployments of submodules and sub-submodules.

Comparable to the aforementioned git-ftp.py, yet written in PHP. PHPloy also supports rollbacks and multiple servers.

PHPloy →

psdiff – .psd previews for git

filp@filp-x ~/dev/myproject
> $ git status

## master
A  mock.psd

filp@filp-x ~/dev/myproject
> $ git commit -m "Add mock.psd"

psdiff: created mock.psd.png # <----------
[master 1156ea5] Add mock.psd
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 1.psd
 create mode 100644 1.psd.png

If you have Photoshop psd files lying around your git repository, you probably already know there’s no easy way to track any changes to them — you have to launch Photoshop and manually inspect them, and if you’re not a designer or don’t have Photoshop installed on your device, you’re fresh out of luck.

Enter psdiff, a git commit hook to automagically render .PSD files to images, allowing you to visually diff changes. The result is an extra .png which is created on the fly and which sits next to the .psd file.

Whilst it’s not a great idea to store your PSDs in Git, psdiff a great example of what one can achieve by using a Git pre-commit hook.

psdiff →

Looking for “real” PSD versioning? Check out the aforementioned LayerVault.

Making ‘git rebase’ Safe on OS X

When performing a large rebase with several commits and many changed files on OS X 10.7+, the rebase process can randomly abort, stating that there are uncommitted changes and rebase cannot continue. However, a git status does not report any changes.

Fix is to set core.trustctime to false. Run the command below to do so:

git config --global core.trustctime false

Detailed explanation: A Simple Tweak for Making ‘git rebase’ Safe on OS X →