GIT

GIT

It took me very, very long. The screencast of Ralf Ebert was/is stored on several on my computers, my phone, my USB stick.. and I didn’t manage to watch it. For weeks, probably months. It was a leftover for when I started diggin’ a bit deeper into git. It started hunting me whenever I sat down in front of one of my machines or was turning to them.

From the very first beginning with git I had a bit problems with understanding how the branches worked. The reason why the exist always was quite obvious to me. But how you actually merge them and what they do to your files I never fully understood until I saw that screencast. Then it made click. At least when it comes about how branches are merged and how to fix the conflicts.

I can also recommend his quick tutorial for starting with git: Link

I’m gonna go now and delete the copies of this, which have spread far too wide on my systems…: http://vimeo.com/16395537

Torvalds should sometimes be beaten for making tools with just too many options that fulfill every task you can think of. Nerd :/

Un-Track files (2012-03-24)

For removing tracked files from the repository, you can use

$ git update-index --assume-unchanged [path]

to get it out.

$ git update-index --no-assume-unchanged [path]

will get it back in again.

In general: use the .gitignore file to keep files out of the repository.

Breakup changes into different commits

If you’ve done several changes at once, but you just want to commit a part of them and keep some of them out of the repository for now, then you can break up the changes into several commits as well. Maybe it’s just to keep the commit history clear, maybe you just like it that way better.

Commit your changes with:

$ git add -p

Then git will open an interactive session and go step by step through all the changes you’ve done to the file and ask you if you want to commit them or not. All changes you’ve committed once will - of course - not be asked for again later. Source

Using multiple SSH keys with github

You might want to use different SSH keys for accessing different repositories on github. What you need to know is that git relies on the local ssh configuration to know which ssh key to use. By default it always uses the id_rsa key. To make it separate between ssh keys, you need to modify you ssh configuration file in ~/.ssh/config

Host me.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/me_rsa

Host work.github.com
    HostName github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/work_rsa

But that’s not enough. You also have to tell SSH to use the new key you’ve created:

$ ssh-add ~/.ssh/work.rsa

Make also sure that GIT actually uses the hostnames you’ve specified in your ssh configuration:

$ git remote -v | grep origin
origin  git@oslopolitimoro.github.com:oslopolitimoro/oslopolitimoro.github.com (fetch)
origin  git@oslopolitimoro.github.com:oslopolitimoro/oslopolitimoro.github.com (push)

Source