Posts Tagged ‘git’

Posting to pastebin from git

Thursday, February 11th, 2010

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.

Saving your neck when git-svn dcommit fails

Wednesday, March 18th, 2009

Over the weekend I had to send some changes to an SVN repo. Thing is that I use git-svn to have all those XXI century benefits like local commits.

Sadly I had some problems with git-svn, concretely it failed half the way through sending my really big number of changes. The result was that I was left with uncommitted changes and missing commits after such set of changes. No need to say that I was really nervous about the state of my hard work of the week…

So after some desperate google searches and some questions to my personal GIT expert, desrt, I found this mail in google groups. I reproduce the process here:

How to save your neck when git-svn dcommit fails half through the process

  1. Open .git/logs/HEAD
  2. Look for your most recent commit (note that these commits are sorted by “unix time”, although you can also find the latest one by reading the shortlog there
  3. Confirm that the commit you found is the right one: git show
  4. git reset --hard hash from log
  5. git svn rebase
  6. git svn dcommit

This picks up where it left off, so you won’t loose anything, happy happy happy git :-) .

Hope this saved your neck like it saved mine. Other tips welcome :-) !

Update: Mike lets me know that the commands were bad written because of html entities and stuff, fixed now.