Merging a subdirectory of a separate Git repository

In the repository being merged:

git checkout -b temp
git filter-branch --prune-empty --subdirectory-filter <subdirectory>/ temp

In the repository the subdirectory is being merged into:

git remote add other ../<other-repository>
git fetch other
git merge -s ours --no-commit --allow-unrelated-histories other/temp
git read-tree --prefix=<path> -u other/temp
git commit


The output of the merge should look something like this:

$ cd other-repository
$ git checkout -b temp
Switched to a new branch 'temp'
$ git filter-branch --prune-empty --subdirectory-filter other/ temp
Rewrite 82e8de6f33e9e4e797e0331aac1fc602f68f6bfa (13/13) (0 seconds passed, remaining 0 predicted)    
Ref 'refs/heads/temp' was rewritten
$ cd ../repository
$ git merge -s ours --no-commit --allow-unrelated-histories other/temp
Automatic merge went well; stopped before committing as requested
$ git read-tree --prefix=other -u other/temp
$ git commit
[feature/merge bc00b33] Merge remote-tracking branch 'other/temp' into feature/FTD-768-build

Interesting papers (2016)

Interesting papers (2015)

  • Holistic Configuration Management at Facebook

    How Facebook manages and distributes configuration - from small JSON files to huge machine-learning datasets - at a massive scale.

  • The impact of syntax colouring on program comprehension

    Advait Sarkar, 2015.

    Study measuring the effects of syntax highlighting - notably that it is useful, and programmers spend less time focusing on keywords when using it.

  • Google Votes: A Liquid Democracy Experiment on a Corporate Social Network

    Hardt, Steve and Lopes, Lia C. R., 2015.

    An experimental voting system built and used inside Google that uses software to mix direct and representative democracy by allowing users to vote directly or entrust their vote to another user.

  • Scaling Agile at Spotify

    Henrik Kniberg & Anders Ivarsson (2012).

    Describes how Spotify has previously organised their engineers into tribes, squads, chapters and guilds; aiming to avoid layers of bureaucracy and other problems often associated with large numbers of employees.

Error handling in Rust

A short cheatsheet for dealing with Return values in Rust.

When a Result is Ok<T>:

let result: Result<&str, &str> = Ok("Succeeded");

result.is_ok() == true;
result.is_err() == false;

result.ok() == Some("Succeeded");
result.err() == None;

let other_result: Result<&str, &str> = Ok("Other result");
result.and(other_result) == Ok("Other result");
result.or(other_result) == Ok("Succeeded");

fn example(string: &str) -> Result<&str, &str> { Ok("Example") }
result.and_then(example) == Ok("Example");
result.or_else(example) == Ok("Succeeded");

When a Result is Err<E>:

let result: Result<&str, &str> = Err("Failed");

result.is_ok() == false;
result.is_err() == true;

result.ok() == None;
result.err() == Some("Failed");

let other_result: Result<&str, &str> = Ok("Other result");
result.and(other_result) == Err("Failed");
result.or(other_result) == Ok("Other result");

fn example(string: &str) -> Result<&str, &str> { Ok("Example") }
result.and_then(example) == Err("Failed");
result.or_else(example) == Ok("Example");

When an Option is Some<T>:

let option: Option<&str> = Some("Example");

option.is_some() == true;
option.is_none() == false;

option.unwrap() == "Example";
option.unwrap_or("Other") == "Example";
option.expect("the world is ending") == "Example";

When an Option is None:

option.is_some() == false;
option.is_none() == true;

option.unwrap(); // panic!()
option.unwrap_or("Other") == "Other";
option.expect("the world is ending"); // panic!("the world is ending")

Backups are important

Your laptop will die. Your hard drive will fail. You will lose your USB key. You’ll have a power cut halfway through typing up your essay. Accidents happen, and making sure you don’t lose work - especially assignments and essays - is important.

Any important work you do should be saved in multiple places. At a minimum, you should have at least two copies on physically separate devices. Preferably, you should have a third copy - this means that if one copy is destroyed or inaccessible, you still have two copies, and are still protected from a second device failing.

Geographical separation is also useful, and makes it much harder to lose work - this doesn’t need to mean keeping copies of your work in another country, but you should avoid keeping multiple copies in the same place. For example, if you have one copy on a laptop and another on a USB key, you may want to consider not keeping them in the same backpack - if the backpack was stolen, you would lose both copies of the work.

Work in progress

As well as making sure you have multiple copies of your files, you should make sure that you save changes to your files while you are working on them. Most editors will have a feature that automatically saves a copy of your work every few minutes - make sure you enable it. You don’t need to make a full backup every time you write a sentence, but making sure your work is saved regularly will save you from losing all the work you did that day when your word processor crashes or your laptop runs out of battery.

Online file storage

Various online services allow you to synchronise files and folders between online storage and multiple computers. This is one of the easiest ways to ensure you have backup copies of your work, and is extremely useful when working on something from multiple computers. You can also access your files though a web browser or mobile application, so you’re almost always able to access them.

Online storage services generally have a free plan, with paid plans available for additional features or extra space. This post doesn’t cover their paid features, and unless noted each service has applications for Linux, OSX and Windows, as well as Android and iOS phones.

  • Dropbox provides 2GB of storage (with extra space for using certain features or recruiting people), keeps a 30 day history of changes to files, and has applications for almost any device or operating system.
  • Google Drive provides 15GB of storage, and integrates with a set of office software that you can use from your browser or phone (word processing, spreadsheets, presentations). It’s missing a Linux application.

If you have existing services or devices you want a service to work with, Amazon and Apple also provide their own storage offerings: Amazon Cloud Drive provides 5GB of space, though doesn’t have much to show off aside from being available on Amazon Fire devices. iCloud is part of iOS and OSX, and you need an Apple device to use it, and there’s no Android client.

Version Control

Git can be used to incrementally record changes to your work and push/pull them to other repositories. Mercurial is a simpler and more user friendly alternative to Git, but both will need you to spend some time learning how version control systems work and how to use the tools they provide. For Computer Science students, basic knowledge of how to use Git and version control is essential, and it’s worth knowing how to use at least one version management system well as it’s almost essential for any software project. Various hosting services for Git allow you to store and publish repositories online.

  • GitHub is the most popular, and is used for many open source projects. You can publish an unlimited number of public repositories, but private repositories either require the Student Developer Pack (which provides 2 private GitHub repositories along with many other goodies), or a paid plan.
  • BitBucket provides unlimited public and private repositories. It’s similar to Github, but provides some different features and is aimed at companies and teams rather than individuals.

You can use Git and Mercurial on your own server with nothing more than SSH access, though there are also applications that will provide an interface similar to Github or Bitbucket. I’d suggest looking at GitLab or Gitorious if you plan on doing this.


  • Remember to regularly save work in progress.
  • Your work doesn’t exist until there are at least two copies.
  • It doesn’t count if those copies are in the same physical location.