Bash History and Git

2014-02-28

Clearly need to work on my Git workflow, but I currently often have test under source control and production under source control, but they are not connected. Further, I’d been slacking in commits on test, but moved a bunch of changes to production (via an Ant script). So I entered my commits on production, but test has better history and should be the repository template, imho.

All this is to say, I ran some Git commands on directory A (production) and wanted to run the same commands on directory B (test).

So I first turned to the *nix history command to list my recent history, then I copy-pasted into Sublime Text and converted via multiple cursors this (redacted):

<br /> 500 git add files<br /> 501 git ci -m "description"<br /> 502 git st<br /> 503 git diff filename<br /> 504 git add files<br />

to the following:

<br /> git add files;<br /> read -p "Press [Enter] key to continue...";<br /> git ci -m "description";<br /> read -p "Press [Enter] key to continue...";<br /> git add files;<br /> read -p "Press [Enter] key to continue...";<br /> ...<br />
Basically (via multiple cursors) I removed the line numbers and added semi-colons to the recent history commands. Then I deleted all but the ‘git add …’ and ‘git commit -m “…”‘ lines and ran it. But there was a problem. Bash was trying to run all the commands in parallel and there were conflicts. I then discovered the Bash read command, which allows you to run the commands sequentially. Not scalable, but practical for smaller lists of tasks.

Written on February 28, 2014