Skip to content

Instantly share code, notes, and snippets.

View Git Subtree basics.md

Git Subtree Basics

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

Background

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">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<script src="script.js"></script>
</body>
View VueVsReact.md

Vue

// ./Greeter.vue
<template>
    <div>
        <span>{{greet}}, {{who}}</span>
        <button @click="$emit('click')">Click me</button>
    </div>
</template>
<script>
@williamoliveira
williamoliveira / validation.js
Last active December 15, 2016 01:38
Simple object validation code. Loosely based on https://medium.com/javascript-inside/form-validation-as-a-higher-order-component-pt-1-83ac8fd6c1f0#.6yiftk939, 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] = []
errors[key].push(errorMessage)
}
@williamoliveira
williamoliveira / redux-act-inspired.md
Last active December 10, 2016 19:03
redux-act inspired
View redux-act-inspired.md
const createAction = (type) => {
  const actionCreator = (payload) => ({
    type,
    payload,
  })

  actionCreator.type = type
View app_Http_Middleware_ActionCache.php
<?php
namespace App\Http\Middleware;
use Closure;
use App\Services\Cache\ActionCacheManager;
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
/**
* Middleware that will cache controller action responses
View install.sh
Moved: https://github.com/williamoliveira/install.sh
@williamoliveira
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;