Posting to pastebin from git

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.

This entry was posted in English, GNOME, planetgnome, Tips and tagged , , , , . Bookmark the permalink.

11 Responses to Posting to pastebin from git

  1. pvanhoof says:

    That’s cute, and useful. Thanks

  2. Ross Burton says:

    Can’t do you something like

    git format-patch -1 $1 | pastebinit –

    ?

    (note, never written a git alias)

  3. Jonh Wendell says:

    Have you seen http://codepad.org ? I think it’s better than pastebin…

  4. Ray says:

    good tip!

    I’m using:

    [alias]
    paste = !sh -c ‘git format-patch -1 –stdout $1 | fpaste’

    now. fpaste is like pastebinit but for Fedora

  5. diegoe says:

    @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.

  6. diegoe says:

    @Ray: thanks, I’ll update the post I didn’t notice –stdout option.

  7. jessevdk says:

    I use something similar but add xsel to immediately put the url on the clipboard (could be handy).

  8. 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’ –

    ๐Ÿ™‚

  9. diegoe says:

    @Pablo: thanks, great idea. Updated the post with that.

  10. jjardon says:

    Very nice, thank you!

  11. plaes says:

    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.. ๐Ÿ˜›

Comments are closed.