Suppose you have a terminal with two tabs. You click, drag, and let go one of these tabs and it becomes an independent terminal window. After a while, you want to take this terminal window and reattach it as a tab to the previous window. How do you do it ? I have seen the merge windows option in the menus, but that merges all windows into one, which I would then have to revert.
You need to, in the window you want to move, go to View-> Show Tab Bar (if the tab bar isn't showing already).
Then, drag the tab of the window you want to move onto the window you want to move it to.
Update for iTerm 2: In iTerm 2 the setting is no longer exposed in the View menu. Go to iTerm > Preferences > Appearance > Tabs and check "Show tab bar even when there is only one tab". Note that in early releases of iTerm 2 the setting was "Hide tab bar when there is only one tab".
The answer is to hold down command + shift + option whilst dragging the body of the terminal (not the tab) back to the terminal you wish to merge.
You need to click and drag the tab from one window onto the tab bar of the other window to reattach it.
If either window has no tab bar because it is currently showing only one tab, Command + T to open a new tab, perform the action, then close any tabs you don't need. This works for both Terminal and iTerm2.
Full credit to Dan Jameson in the comments for this obvious solution.
I had troubles merging windows with the Hotkey Window profile. I eventually found a way to un-split the windows by doing the following:
Hide tab bar when there is only one tab
- Press your hotkey to show the Hotkey Window
- Click & drag the tab into the Hotkey Window's tab bar
For Terminal (as opposed to Terminal2):
If the window you want to attach has just one tab (I.e. no tab bar) then add another tab. Then drag the tab of the one you want to the tab bar of the window you want to add it to.
I found it took a bit of jiggling before th image changed from an thumb nail of the window to just the tab. This is the signal that your are in the right place!
It took me a while to realise I needed to add another tab but is is logical.