Skip to content

Instantly share code, notes, and snippets.

Created Jul 19, 2019
What would you like to do?
ui = true
default = simple
editor = vim
excludesfile = ~/.gitignore
autocrlf = input
lineNumber = true
tool = meld
tool = meld
st = status -uno
dif = diff
tree = log --pretty=oneline --abbrev-commit --graph --decorate
hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short
sync = !git checkout master && git fetch upstream && git pull upstream master && git push
backport-file = "!f(){ for f in $(git diff --name-only --diff-filter=A ${1}^1..${1}); do git cat-file -p $(git ls-tree ${1} ${f} | awk '{print $3}') > ${f}; git add ${f}; done; }; f"
backport-url = "!f() { echo '\nupstream commit:'; git remote -v | awk '{print $2}' | sed -e 's|:|/|' | sed -e 's|git@|https://|' | sed -e 's|.git$|/commit/|' | uniq; git rev-parse --short ${1}; }; f"
backport = "!f(){ git backport-file ${1} ; git difftool -d ${1}^1..${1} & git difftool -d ${1} -- $(git diff --name-only ${1}^1..${1}); git log ${1}^1..${1} | tail --lines=+5 | sed -e 's|^ ||'; git backport-url ${1}; }; f"

This comment has been minimized.

Copy link
Owner Author

@vkareh vkareh commented Jul 19, 2019

To use the backport commit (using caja as an example)

$ git clone
$ cd caja
$ git remote add nautilus
$ git fetch nautilus

Now the upstream project is set up as a remote in the downstream. Then:

$ git backport <commit hash from nautilus>

This will open two instances of meld: one with the change within nautilus, as reference, and one instance from nautilus to caja. Think of it as a poor-man's three-way diff. Once the right lines are moved from nautilus to caja, close meld and this will show up in terminal:

$ ...
foo bar commit title

commit description blah blah

upstream commit:

So you copy that thing and run git commit -a and paste that, removing the caja line to append the hash to the nautilus URL, ending with the following commit message:

foo bar commit title

commit description blah blah

upstream commit:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment