Moving a git repo to a subdir of an existing repo, keeping history

Via http://www.nomachetejuggling.com/2011/09/12/moving-one-git-repo-into-another-as-subdirectory/.

I wanted to move several git repositories into an existing repo as part of a restructuring of related projects. A quick google turned up the above link and  I reproduced the important parts here for safekeeping, adjusted slightly for Windows:

  1. Get a local copy of the repository containing the project being pulled in
  2. Modify the local copy to move all of the files into a subdirectory
  3. Add the local copy as a fake “remote” to our larger project
  4. Pull the local “remote” in, thereby pulling the entire history along with it
cd old-project
md new-name
move *.* .\new-name 
git commit -a -m "Preparing old project for move"

After that, the old repo contains only 1 folder, new-name, which will become the name of the subfolder of  this project in the target repository.

cd new-project 
git remote add temp https://url-to-old/repository.git
git fetch temp 
git merge temp/master --allow-unrelated-histories
git remote rm temp

Now, push the new-project (or existing project) and you’re done, keeping the history of the old-project in it’s new home.

My toolkit

Everytime I (re)install my development computer I need to think about all the tools I need and use on a regular basis. For that reason, and maybe to inspire others, here’s my list of essentials tools and software for a (Delphi) developer.

Delphi

  • Delphi itself ofcourse. Usually the most recent version, although I always keep the previous version installed as well for bugfixing and patches that might need to be done.
  • GExperts – an open source plugin with many enhancements for Delphi / C++ builder
  • DDevExtension – another open source plugin that greatly enhances the Find/Use unit dialog
  • IDEFixPack – Andreas also makes a great IDE plugin that fixes several IDE bugs in-memory
  • TestInsight – a plugin that lets you run DUnit_ unit tests in your framework. Depending on settings, you can even let it run every time you save or compile your project.
  • FastMM4 – (Almost) every project will benefit from this alternative memory manager, and it’ll help you track down those nasty memory leaks.
  • MadExcept – Stack traces, exception handling, reporting.

Tools

  • Beyond Compare – The best compare and merge tool out there. Especially their 3-way merge of conflicts is better than any I have seen before.
  • Notepad++ – With the right plugins, a very versatile text editor.
  • 7-Zip – Isn’t this the defacto unzipping tool for Windows by now?
  • KeePass 2 – Keeping track of all those hard-to-remember passwords
  • VirtualBox – For running all those different environments you need for testing
  • Paint.NET – More functional than paint, less bulky than other image editors
  • Greenshot – Screenshot tool that can do screen, window or regions and offers image editing immediately integrated
  • SumatraPDF – Who needs Adobe Reader when all you need is view and read PDF files.
  • GrepWin – Text and Regex search for files and contents, for when you know what you need, but not where you left it
  • Bulk Rename Utility – The UI takes some getting used to, but the functionality to rename a bunch of files is sometimes required. And this is the most versatile tool I found so far
  • Expresso – Free regex utility that lets you write, test and validate regular expressions
  • Pencil – Quickly create wireframe UI mock-ups that don’t distract with implementation details
  • TortoiseGIT / TortoiseSVN – Depending on the source control system I’m working with, because despite doing lots of stuff on the command line, I’m still predisposed to using a UI when possible.
  • XVi32 – simple and to-the-point Hex editor.
  • Resource Hacker – to see what’s inside those DLL’s and binaries
  • WireShark – Inspect your netowrk traffic
  • SysInternals suite – I don’t use all of them, but I usually download the entire set to be sure
  • SoapUI – If you ever programmed against a SOAP interface, you’ll have this installed
  • REST Debugger – Free tool for debugging REST interfaces

Note: You can get a lot of these tools in 1 stand-alone installer from Ninite. Silent download and install of the software you select, without any extra’s.

If you have any additions, remarks or alternatives, please let me know!