Revert Latest Commit on a git repo

February 19, 2019

I have changes committed to my branch that I want to revert.

$ git checkout HEAD~1 -- filename.txt

This will look at the file filename.txt, look back one commit from HEAD, and then replace the contents of filename.txt with that version one commit back.

Installing Postgres Client on Amazon Linux

February 11, 2019

I needed to install a postgres client onto Amazon Linux so that I could access my RDS database with it temporarily.


To install:

[ec2-user ~]$ sudo yum install -y

[ec2-user ~]$ sudo sed -i "s/rhel-\$releasever-\$basearch ...

ps to find command line

January 10, 2019

I wanted to use ps on linux to find the full command line that a process was started with. This can be done using the options -eaf

ps -eaf | grep drumcoder                     
root     28382 28322  0 08:18 pts/0    00:00:00 /home/drumcoder/.venv/drumcoder/bin/python /home/drumcoder ...

Tags: ps gunicorn

Debugging gitignore

November 8, 2018

If you have a file being ignored by git and you try to add it, you'll get a message something like this:

The following paths are ignored by one of your .gitignore files:
Use -f if you really want to add them.

To find out ...

Finding string in BASH array

November 5, 2018

I had a need to go through an array variable in bash and see if certain strings were present in the specified order. The existing code looked for values at specific array indexes, but this was deemed too fragile. The fix was to make sure that the strings were present ...