Skip to content

Instantly share code, notes, and snippets.

View initial tracking
Scenario | Tracking set up
Clone a (non-emtpy) repo, use the branch which is checked out automatically | Y
Push a branch to a remote, that doesn't exist on the remote | N
Push a branch to a remote, that doesn't exist on the remote, with push -u | Y
Checkout a branch from a remote, without -t (specified or implied) | N
Checkout a branch from a remote, with -t (specified or implied) | Y
canton7 / gist:1053846
Created Jun 29, 2011
git push, tracking, and push.default
View gist:1053846

git clone path/to/test/repo.git

push.default = matching (the default)

git config push.default matching

git branch -a
   * master
View Installing LaTeX and

Installing LaTeX + TeXstudio

  1. Grab MiKTeX 2.9 and install. It doesn't really matter whether you get the complete or basic system, as the basic system will download packages as needed.
  2. Grab TeXstudio and install.
  3. Fire up TeXstudio and hit Options -> Configure TexStudio.
  4. Under "Commands", change "Bibtex" from "bibtex %" to "bibtex8 %" (bibtex8 is later and greater and is needed for biblatex, which is better than bibtex for reference handling).
  5. Under "Quick Build", check "PdfLaTeX + Ldf Viewer". Not all LaTeX compilers were created equal, and Pdf is likely the format you'll want.
  6. If you're feeling adventurous, go to "Editor" and change the font family to "Consolas" :)
canton7 / gist:1193421
Created Sep 4, 2011
Different ways of creating new local tracking branches
View gist:1193421

Ways to create a new local branch, tracking a remote branch

Create a new local branch with the same name as the remote one

git checkout <remote_branch_name>
git checkout -t <remote>/<remote_branch_name>

Create a new local branch with a different name to the remote one

canton7 / gist:1268587
Last active Oct 18, 2016
git merge -s theirs
View gist:1268587

How to do a git merge -s theirs

One way of many...

This is one way which keeps the history looking like you'd expect.

Command is equivalent to git checkout MINE; git merge -s theirs HERS.

canton7 / gist:1339179
Created Nov 4, 2011
Useful git aliases
View gist:1339179

Useful git aliases

Command-line graphical log viewer

This is invaluable if you've managed to get yourself in a muddle.

git config --global alias.graph git log --graph --oneline --decorate --all
canton7 /
Last active Jun 11, 2022
Local versions of tracked config files

How to have local versions of tracked config files in git

This is a fairly common question, and there isn't a One True Answer.

These are the most common techniques:

If you can modify your application

canton7 /
Created Jan 6, 2012
Workflows for long-running feature branches

Workflows for long-running feature branches

These examples were created during a discussion with j416 on #github about how best to manage long-running feature branches.

The scenario is this: You have a long-running feature branch, based off master. The feature branch and master both touch the same parts of the same files, so you know that there will be conflicts when you finally merge the feature branch in. What can you do to minimise the conflicts?

canton7 / Sample DataMapper model.rb
Last active Sep 10, 2018
Sinatra Auth in a Box
View Sample DataMapper model.rb
# From bcrypt-ruby gem
require 'bcrypt'
class User
include DataMapper::Resource
attr_accessor :password, :password_confirmation
property :id, Serial
property :username, String, :required => true, :length => (2..32), :unique => true
property :password_hash, String, :length => 60
canton7 / gist:2146783
Created Mar 21, 2012
View gist:2146783


This is a little monkey-patch to add a new method to Enumerable, #with_props.

You use it something like this:

[1, 2, 3, 4].each.with_props do |element, props|
   puts "First? #{props.first?}"