Skip to content

Instantly share code, notes, and snippets.

View Git Subtree

Git Subtree Basics

If you hate git submodule, then you may want to give git subtree a try.


When you want to use a subtree, you add the subtree to an existing repository where the subtree is a reference to another repository url and branch/tag. This add command adds all the code and files into the main repository locally; it's not just a reference to a remote repo.

When you stage and commit files for the main repo, it will add all of the remote files in the same operation. The subtree checkout will pull all the files in one pass, so there is no need to try and connect to another repo to get the portion of subtree files, because they were already included in the main repo.

Adding a subtree

Let's say you already have a git repository with at least one commit. You can add another repository into this respository like this:

View index.html
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<link rel="stylesheet" href="styles.css">
<script src="script.js"></script>


// ./Greeter.vue
        <span>{{greet}}, {{who}}</span>
        <button @click="$emit('click')">Click me</button>
williamoliveira / validation.js
Last active December 15, 2016 01:38
Simple object validation code. Loosely based on, writen in a more easy to understand manner
View validation.js
const getErrors = (inputData, validationRules, globalOptions) => {
const errors = {}
const addError = (key, errorMessage) => {
if(!(key in errors)) errors[key] = []
williamoliveira /
Last active December 10, 2016 19:03
redux-act inspired
const createAction = (type) => {
  const actionCreator = (payload) => ({

  actionCreator.type = type
View app_Http_Middleware_ActionCache.php
namespace App\Http\Middleware;
use Closure;
use App\Services\Cache\ActionCacheManager;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
* Middleware that will cache controller action responses
williamoliveira / AbstractRepository.php
Last active October 29, 2015 11:48
AbstractRepository com um exemplo de UserRepostory
View AbstractRepository.php
<?php namespace App\Repositories\Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
abstract class AbstractRepository
protected $modelClass;