Some bash/git trickscd -Switches back to the directory where came from before the most recent
cd.
git checkout -Switches back to the previously checked-out branch or commit.
sudo !!Repeat the previously executed command, but this time with superuser rights. Careful! (The shell expands the
!! before it executes anything; i.e., this is not a property of
sudo.) There are
magnificent apps that bring this idea of command-fixing to the extreme.
git switchgit restoreAround git 2.26, these appeared, they're intended as alternative commands for
git checkout. These make it clearer whether you want to switch the checked-out branch (and the contents of the worktree along with it), or merely put some files from the same/another branch into the working directory. The manual says:
THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE. I feel you should still teach these instead of
checkout, because
checkout confuses newbies.
geany $(ack -l Wurst)Open in the text editor (geany in my case) all files in the current directory (recursing through subdirectories) that contain the string
Wurst. Here,
ack is a better
grep for searching through an entire directory of text files, and I warmly recommend
ack. You can build a similar command line with
find and
grep, but it will of course be longer.
git diff --cached --name-onlyPrint all files that
git status would show as changed
and added, but not yet committed. Like the previous item in this post, you can wrap this in
yourTextEditor $() to open the files in one shot:
geany $(git diff --cached --name-only)git diff --name-only --diff-filter=UPrint all files with unresolved merge conflicts. Again, mostly useful to wrap in
yourTextEditor $(), because otherwise the plain
git status remains king.
Lengthy commands can always become your own shell scripts or
git aliases; see
my aliases.
git purr :3
-- Simon