Skip to Main Content
TWIL
bash
git
Image representing this week's "TWIL" blog post on coding shortcuts, Git flag optimizations, and commit amendment techniques.

Welcome to "TWIL," our weekly digest empowering micro-learning of tech's most engaging complexities. This week, Katie unveils shortcuts for seasoned and aspiring coders alike. Learn the subtle art of tweaking commands with Edit and Re-run Previous Shell Command in Shell, where a simple 'fc' unfolds into a streamlined command-editing workflow. Navigate Git with ease as Katie illustrates how to shorten Git flags intelligently; recognizing when a fragment of a flag is enough to command attention. Finally, perfect your commit game with insights on using Commit Amend with the Same Message in Git, turning omissions and errors into seamless corrections.

Edit and re-run previous shell command

To edit and re-run the previous shell command:

fc

This will open up the previously-run command to edit in Vim; this can be useful for correcting typos in long commands or rearranging flags/args easily.

To run the updated command, just write-quit in Vim and the edited command will be run in the shell upon exit.

  • Shell
Katie Linero's profile picture
Katie Linero

Senior Software Engineer


Git flag shortening

When using git, you only need to type the flag as far as it is ambiguous. For example:

--no-edit:

--no-e

--force-with-lease:

--force-w
  • Git
Katie Linero's profile picture
Katie Linero

Senior Software Engineer


Commit amend with same message

If you want to simply amend a commit without changing the message (I personally use this a lot for correcting typos or leftover comments I catch after I've already committed, for example):

git commit --amend --no-edit

Documentation for --amend:

https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend

Documentation for --no-edit:

https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend

  • Git
Katie Linero's profile picture
Katie Linero

Senior Software Engineer

Related Posts

Digital pioneer journeying through technological quirks, reminiscent of vast waterfalls and rocky terrains
April 5, 2017 • Kyle Misencik

Infinitely dispatching actions + React, Redux & React Router v4

While implementing JWT for an application, we ran into a quirk with React Router v4. Here, we hope to show how to implement protected client-side routes while avoiding some of the pitfalls we encountered.

Turtle swimming close to a life preserver as a metaphor for developers using Git version management to stay afloat
May 4, 2017 • Nick Farrell

Life-Saving Git Tips

From salvaging lost commits to streamlining your workflow, discover how to make your coding life smoother and avoid common pitfalls.