Tag Archives: git

make vim always start git commits on the first line

Vim has a (oftentimes) nice feature of remembering where in a file you were when you open it again. Which is all well and good, but it’s based on filenames, and git commit messages are always the same. So it remembers the line number where I finished my last commit message. I always want git commit messages to open up on the first line. Here’s some vimrc magic to make it Do The Right Thing™

" don't remember the cursor position in git commits
au FileType gitcommit au! BufEnter COMMIT_EDITMSG call setpos('.', [0, 1, 1, 0])

Combining two git repositories into one

I went down some dead ends trying this, but it was pretty easy in the end. Here’s how I did it, because my search keywords didn’t turn up what I was looking for first.

I have two repositories, AAA and BBB, and I want them to end up looking like below. Also, I don’t want to keep using the old repositories, but I do most definitely want to see the full history of each file.


Or something along those lines anyway. I chose AAA to be the new final parent, so I started by moving all the original AAA files down a level. This was straightforward

    cd AAA
    mkdir aaa-oldAAA
    git mv x y z aaa-oldAAA
    git commit

I then did the same thing in the BBB repository.

Now, the fun, adding the other repository as a remote in this repository.

    cd AAA
    git remote add bbb-upstream /full/path/to/old/BBB
    git fetch bbb-upstream
    git checkout -b bbb-u-branch bbb-upstream/master

This is pretty neat. Right here, you’re only looking at the code from the BBB repository! If you git checkout master again, you’re back looking at your AAA/aaa-oldAAA repository. This makes sense when you think about it, nothing says that branches have to have the same or even related code in them.

Now, we just merge the bbb-u-branch into our local master!

   git checkout master
   git merge bbb-u-branch
   git remote rm bbb-upstream # no longer needed

Presto! Finito! The only problem I had was a merge conflict in the .gitignore files.

Note: to see the logs of files that have been moved, you need to use git log --follow filename.blah This has nothing to do with the dual merge however.

putty, pageant, git and github. key problems

FATAL ERROR: Disconnected: No supported authentication methods availableGithub’s help on this isn’t actually very good.  And the solution is really quite easy when you get it working.

  1. You _DO_ want to use plink for ssh when you’re installing msysgit.
  2. Putty’s public key that you have saved isn’t in the right format for pasting into github.
  3. fire up puttygen again, but choose to LOAD AN EXISTING KEY
  4. copy and paste from _there_ into github.

Do not try things like opening up your saved public key, removing the comment lines, and adding “ssh-rsa” to the front or things like that.  It won’t work.

If you get this of these, you’re doing it wrong:

  • FATAL ERROR: Disconnected: No supported authentication methods available

Some of the other advice on the net is for problems where plink can’t talk to pageant.  To make sure that’s not the case, you need to try using plink directly to login to github.

C:\somewhere>"c:\Program Files\PuTTY\plink.exe" -v -agent git@github.com

Looking up host "github.com"
Pageant is running. Requesting keys.
Pageant has 1 SSH-2 keys
Using username "git".
Trying Pageant key #0
Server refused public key
Disconnected: No supported authentication methods available
FATAL ERROR: Disconnected: No supported authentication methods available

If you see that pageant is running, and it has a key, but it isn’t working, that’s a SURE sign that you just haven’t been able to convert the putty key format into a suitable format for github.