I usually need to show someone a simple patch from a local git repo, my method was to run git format-patch and upload the result to my gnome.org userdir with a script conveniently called internets. This of course filled my userdir with garbage in the long run and also was a multiple step process.
So today, after a quick apt-cache search, I installed pastebinit, but then my problem was that there is no glue between this tool and git. Some googling took me to mentions of git-porcelains but I didn’t want to install that so I tried something simpler, a git alias.
I crafted this line for .gitconfig:
pastebinit = !sh -c 'git format-patch -1 โstdout $1 | pastebinit -f diff' -
Update: Ray and Pablo shared some ideas in the comments, the alias is updated, thanks!.
That I can use like this:
git pastebinit [commit]
It runs and outputs the url of my new pastebin’d code :-). I’m happy with it, but open to suggestions. Hope it’s useful for someone.
That’s cute, and useful. Thanks
Can’t do you something like
git format-patch -1 $1 | pastebinit –
?
(note, never written a git alias)
Have you seen http://codepad.org ? I think it’s better than pastebin…
good tip!
I’m using:
[alias]
paste = !sh -c ‘git format-patch -1 –stdout $1 | fpaste’
now. fpaste is like pastebinit but for Fedora
@Ross: no, that was one of my first options but that just posts the file name, like ‘0001-shift-control-click-is-not-shift-click.patch’ to pastebin. Also it leaves that file in the current dir.
@John: nice! I’ll try that soon.
@Ray: thanks, I’ll update the post I didn’t notice –stdout option.
I use something similar but add xsel to immediately put the url on the clipboard (could be handy).
Hi Diego, that’s a great idea!
I tuned the script up a little bit more to support highlighting:
pastebinit = !sh -c ‘git format-patch -1 –stdout $1 | pastebinit -f diff’ –
๐
@Pablo: thanks, great idea. Updated the post with that.
Very nice, thank you!
Although, I’m using a script for paste.pocoo.org, I’m using following:
git show [commitid] | lodgeit.py [-p]
Where -p is for private pastes.. ๐