Skip to content

Instantly share code, notes, and snippets.

View AlfiyaZi's full-sized avatar
🎯
Focusing

Ziganshina Alfiya AlfiyaZi

🎯
Focusing
  • Bremen
  • 06:18 (UTC -12:00)
View GitHub Profile

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

#!/bin/bash
set -u
# Clones and softlinks a git repo, _if needed_.
# Summary of steps:
# 1. Checks that the provided repo is valid (SSH or HTTP)
# 2. Compares local and remote commit to see if there is a new version
# 3. Clones the remote commit in local, adding -<timestamp>-<commit> to the folder name
# 4. Deletes .git directory of the cloned repo
@AlfiyaZi
AlfiyaZi / git-squash.bat
Created April 7, 2021 17:05 — forked from jotaelesalinas/git-squash.bat
Easy git-squash (merges last N commits in one)
@echo off
if "%1"=="" goto blank
echo Squashing %1 commits...
git reset --soft HEAD~%1
git log --format=%%B%%n --reverse "HEAD@{1}" -n %1 > _msg.txt
git commit -t _msg.txt
del _msg.txt
echo Done!
@AlfiyaZi
AlfiyaZi / BackgroundPty.py
Created February 10, 2021 13:34 — forked from daryl314/BackgroundPty.py
Execute in a background pseudo-terminal
import pty, sys, os, re, tty, select
class ReadBuffer(object):
"""Buffer read operations"""
def __init__(self, fd):
if isinstance(fd, file):
fd = fd.fileno()
self.fd = fd

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@AlfiyaZi
AlfiyaZi / aggregation_lookup.md
Created March 16, 2018 12:25 — forked from bertrandmartel/aggregation_lookup.md
MongoDB $lookup aggregation example

MongoDB $lookup aggregation

SO link

db.votes.aggregate([{
    $lookup: {
        from: "users",
        localField: "createdBy",
        foreignField: "_id",
@AlfiyaZi
AlfiyaZi / create_index.sh
Created March 13, 2018 11:43 — forked from bonzanini/create_index.sh
Elasticsearch/Python test
curl -XPOST http://localhost:9200/test/articles/1 -d '{
"content": "The quick brown fox"
}'
curl -XPOST http://localhost:9200/test/articles/2 -d '{
"content": "What does the fox say?"
}'
curl -XPOST http://localhost:9200/test/articles/3 -d '{
"content": "The quick brown fox jumped over the lazy dog"
}'
curl -XPOST http://localhost:9200/test/articles/4 -d '{
@AlfiyaZi
AlfiyaZi / uber.yaml
Created February 3, 2018 16:17 — forked from earth2marsh/uber.yaml
A Swagger YAML specification for Uber's new API
swagger: 2
info:
title: The new Uber API
description: Move your app forward with the Uber API
version: "1.0.0"
host: api.uber.com
schemes:
- https
basePath: /v1
produces:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright (C) 2009 Facebook
# Copyright (C) 2010, 2011 Tipfy.org
# Copyright (C) 2011 Yesudeep Mangalapilly <yesudeep@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@AlfiyaZi
AlfiyaZi / graph.py
Created December 8, 2017 17:33 — forked from theonewolf/graph.py
Dijkstra's Recipe in Python Example (shamelessly stolen; links embedded)
#!/usr/bin/env python
graph = {
'N1': {'N2': 1},
'N12':{'N13':1},
'N2': {'N4': 1, 'N13':1},
'N4': {'N5': 1, 'N12': 1},
'N5': {'N6': 1},
'N6': {'N7': 1},