This is a problem that i encounter sometimes: I’ve committed on the master or dev branch when in fact i wanted to do those commits on a feature branch like feature-foobar. Let’s fix that.

Important: don’t do this when you’ve already pushed your commits to a remote.

  1. Checkout the branch in which you made the commits to be moved. e.g.: git checkout master
  2. Create and checkout the feature branch where you wanted the commits to be in te first place. e.g.: git checkout -b feature-foobar
  3. Checkout the main branch again. (See 1).
  4. Reset this branch a number of commits (use git log --decorate) to see how many commits you want gone from the main branch and moved to the new one. Use this number in the reset command. In my case, i want 5 commits moved: git reset HEAD~5

And that’s it really. Simple as that!

Advertisements

I recently discovered the awesome GNU Stow application (works on unix-like systems like GNU/Linux or Mac OSX). Stow is a symlink manager, that allows you to easily deploy and remove files to or from a directory.

Setup

Let’s say you have some configuration files in your home directory (eg: .bashrc, .vimrc and a config directory .vim) and you want to have them in git to be able to track your changes and such. It’s not a really good idea to make your whole home directory a git repo. That’s where Stow comes in. Just create a configuration directory, for instance ‘dotfiles’, and create a subdirectory for every app you have configs for. Then place the appropriate files into the right subdirectory, like this:

/home
    /{user}
        /dotfiles
            /vim
                .vimrc
                /.vim
                    ...
            /bash
                .bashrc

You can now make the dotfiles directory a git repository, and keep your dotfiles safe in git. But they’re not yet in the right place, so we’ll ask our symlink manager to fix that for us.

Create symlinks

  1. cd to the dotfiles directory
  2. You can make Stow symlink the files to your homedir like so:
    stow {package}
    where you replace {package} with the name of the subdirectory you created earlier.
  3. If you now want to remove a certain package’s config files, just do this:
    stow --delete {package}

How to install Stow

On Mac OSX

Use Homebrew:
brew install stow

On GNU/Linux

Install stow using your favorite package manager, e.g.:
apt-get install stow

That’s it!

Ubuntu Quick Work Setup

January 4, 2013

Today i installed a dual boot Ubuntu setup on my computer at work. I used the Wubi installer with Ubuntu 12.04 LTS. Here’s what i did to get started pretty quick:

1. Update and upgrade:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade

2. Install some software

  • sudo apt-get install git tig chromium-browser apache2 php5 php5-mysql php5-sqlite php5-gd php5-curl php5-xdebug php5-memcached php5-imagick php5-intl phpunit mysql-server vim ffmpeg curl inkscape vlc tree
  • I manually installed Sublime Text 2, a launcher, and some add-ons for it

3. Configure some software

  • Firefox and chrome: tabs, startpage, sync
  • Thunderbird + Exchange setup: my previous post
  • git: global settings (user, email, colors)
  • apache:
    • sudo a2enmod rewrite to enable mod_rewrite
    • sudo a2enmod vhost_alias to enable VirtualHosts
    • Added VirtualDocumentRoot phrase to /etc/apache2/sites-available/default
  • I also set up dropbox to brainlessly sync between my work’s windows and ubuntu setups

That’s about it. Took me less time than i thought it would.

Regards
Toon

As you could read in my previous posts about this topic, you know that i have to code on a windows computer. I just recently changed my setup for the better.

– I installed the latest firefox and chrome browsers.

– In firefox, i installed the following plugins: Firebug, Ghostery, FireFTP, FireSSH, PDF Viewer (pdf.js), and HttpFox. These let me do a lot of work easily from my browser instead of from an extra piece of software i would have to install.

– I installed the Thunderbird mail client with DavMail, to support the Exchange mail and contacts server, and i added Lightning addon for calendar support.

– Really important, for developers, is their text editor or their IDE. I chose Sublime Text 2, the multi-platform, genious text editor. This means Productivity times 10 for me.

– Furthermore, i installed the official Git package for windows, which includes Git Bash and Git Gui. Git Bash then includes a MingW console, which is really cool and owns the cmd.exe console big time (you can do unix-style commands like cd, ls -al, vim, and others).

– Last but not least, the Gimp image editor is also there.

As you can see, i’m naturally still trying to use as much free software as possible, but it’s not always easy. For instance, finding a (gui) text-editor like sublime text 2 is quasi impossible.

That’s it 🙂

Regards
Toon

List of Git references

July 18, 2012

Some time ago i started using Git for my version control needs. I found myself living in the past, and unable to collaborate with others, so i tried some versioning tools and Git came out best, leaving the other options far behind.

Git is a really nice system, and lots of GUI’s are available for all operating systems, but i still find it easier to use and understand if i’m using the command line tools. To understand how Git works, and how you can use the different commands, check out these guides:

Enjoy learning and using Git!

That’s it 🙂
Toon

I always wonder what would be the perfect development setup for me. Graphical? Command line? IDE? Text editor? VCS? Automation? Now it’s time to sum some things up for myself. (To make sure we speak the same language: i write php, javascript, html, css, and sh. Sometimes a little bit of python.)

I hate IDE’s. They are so bloathed with stuff you don’t need, 99% of the time. But they can be pretty useful… certainly when you have to work with big projects (or other people’s projects), it can help to have a good IDE at hand. Most of the time though, they’re in my way, they create stupid project files, they slow down my laptop and they cost money if you want a decent one. So that’s why i usually let NetBeans sleep, and wake Sublime Text or Vim instead.

Now to compensate for a few things text editors miss, compared to IDE’s. For version control i’m using Git. It’s fantastic. I use vagrant shared folders to have my code right on the development environment while developing.

For debugging, i usually use the php-cli tool in the terminal or Xdebug in the browser. To cope with a lot of ouput, i’ve colorized my prompt line, so that i can find it easily between two var_dumps.

Almost all the above relies on the power of the command line, and applies to both my Trisquel GNU/Linux and Mac OSX setups. I quite like it. On the contrary, everything above is unavailable at the place where i work. No git, no handy command line debugging (cygwin fails to install), no rsync… only a gedit install without plugins. Read more about that here.

That’s about it! 🙂
Toon