Post navigation

In the Xerox Palo Alto Research Center between 1973 and 1976, Larry Tesler implemented the first version of what will be later known as the Copy-Paste tool. This tool is indeed very handy especially in graphical user interfaces and I guess we no longer can still live without it, but it also can be pretty convenient in text-based interface (as the terminal) without requiring the mouse.

Let’s say you’re working on a new local branch (based on master) and you did multiple commits that are closely related. You might want to squash these latest commits into a single one. Git does not provide a direct way to do this but the steps are pretty much straightforward.

Here is what you need to do in two steps:

First you need to soft reset your working directory to master:

git reset --soft master

This will undo the commits but will leave the changes you did.

Then all you have to do is to commit those changes all together:

git ci -m "your commit message"

In order to simplify these steps you can also add an alias in your git config:

squash = "!f() { git reset --soft master && git ci -m \"$1\"; }; f"

You will then use it this way:

git squash "your commit message"

Of course this is helpful only in the case where (1) your branch is based on the master and where (2) you need to squash all the recent commits of your branch since the master.

If that’s not your case you can change the first step to use HEAD instead, like this for example:

git reset --soft HEAD~3

Which will undo the last 3 commits.

So here you go, how to squash your latest commits into a single one.
You can play with the last command and put the number of the last commits you want to squash as a parameter in the git alias if you want to.

When renaming/moving a file, git log /path/to/file will only show the commits history from that renaming/moving until now. To follow the commits until the first one and display them in the history you will need to do a

git log --follow /path/to/file

All the commits will be shown in the history. But note that this will work only for a single file.

If you’re using Egit in Eclipse, you can do the same by checking the box Follow Renames in Preferences -> Team -> Git -> History

PS: If you want to move a file in a git repository, you can consider using git mv oldpath newpath which is a shorthand for

This month I was invited to the december session of HumanTalks Paris where I did a quick presentation about Scala. I talked about some basic principles of the langage and introduced the functionnal programming paradigm.

Let say you are on the master branch and you want to do some devs without messing up your master. What one usally do is create a new branch dev based on the main branch (in this case master) and do all the developments there.

Sometimes you may want to copy just one or two files from this dev branch without merging the whole branch with master.

The easiest way to do so is the following (assuming you are in another branch than dev):

git checkout dev -- path/to/your/file

Note that you can also get a whole folder, all the files inside this folder will be copied:

git checkout dev -- path/to/your/folder

For more informations on checkout, take a look at the man page git checkout

Circular Dependencies are bad, really bad, and you should fear them as much as you would fear wolves in a dark forest by a dark winter night !

But sometimes, you have no other choices, and you have to face them, at least temporarily. And in this case, if you use Eclipse, you’ll not be able to launch your application because your favorite IDE does not want to compile your projects.

But (because there’s always a but), you can force it to compile them by doing this simple manipulation:Preferences -> Java -> Compiler -> Building -> And then set “Circular Dependencies” to “Warning”

Now Eclipse should compile your workspace correctly.
And don’t forget to resolve the circular dependency ASAP.

If you’re developping in Django and want to use some client-side frameworks like Backbone.js or Angular.js, may be you are wondering how to mix both of these client and server side frameworks especially if they are using very similar tags as {{ tag }}.

The solution came with django 1.5 and its brand new verbatim tag. If you want to insert client-side framework tags inside your django templates, just surround your code like this :