Git: Reset a local branch to last remote commit, remove unstages files, and fix file permissions

I use the Codeanywhere online IDE for my WordPress development. Sometimes I screw up something I’m testing (usually when I try to manipulate the filesystem with PHP) and need to reset my local branch to the last clean commit I sent to remote.

(Note that I said “remote”. I don’t trust local commits. I continually push to remote to have a safe restore point, especially if I need to do a full delete of my local branch. Yes, it has happened more than once.)

Occasionally I find folder permissions screw up as well and I need to reset via the bash command line.

The following commands are what I always come back to.

Note: The “$” in the command below represent the command-line prompt. The actual commands follow it.


Reset a local branch to the the last remote commit of the branch

$ git reset --hard HEAD


Clean up any uncommitted folders/files that the reset didn’t remove

$ git clean -f -d


Set full permission recursively on a folder and all files/sub-folders

Change directory (cd) to the parent folder of the folder you want to set permission on.

$ sudo chmod -R 777 vylesk-module-z1


Recursively delete a folder and all files/sub-folders

Change directory (cd) to the parent folder of the folder you want to delete.

$ rm -rf vylesk-module-z1

Note: The “f” means you are not prompted to delete each file/folder.

Bash: Remove file and folder with Windows style directory names and backslashes

The Problem

While working with zip files in WordPress (I’m setting up my own update server and package update process), I manually created a zip file in using 7zip in Windows (my primary operating system) and extracted it via PHP in a Codeanywhere Ubuntu workspace.

The problem was the zip file was created containing Windows paths, so I ended up file with a file name “vylesk-test-plugin\vylesk-test-plugin.txt” and directory name “D:\Temp\php\vylesk-test-plugin\vylesk-test-plugin.1.1\vylesk-test-plugin\“.
Notice the backslashes and “D:” drive path.

Removing the file and directory was a problem.

Attempting to perform a simple rm and rm -rf resulted in:

rm: cannot remove './vylesk-test-plugin\vylesk-test-plugin.txt': Permission denied
rm: cannot remove '_temp/vylesk-test-plugin.1.1/D:\Temp\php\vylesk-test-plugin\vylesk-test-plugin.1.1\vylesk-test-plugin\': Permission denied

I tried changing file permissions using chmod and that also resulted in:

chmod: changing permissions of 'vylesk-test-plugin.1.1/D:\Temp\php\vylesk-test-plugin\vylesk-test-plugin.1.1\vylesk-test-plugin\': Operation not permitted
chmod: changing permissions of 'vylesk-test-plugin.1.1/vylesk-test-plugin\vylesk-test-plugin.txt': Operation not permitted


The Solution

The solution turned out to be very simple. I just needed to prefix the command with sudo.

So I ended up with:

sudo rm vylesk-test-plugin\\vylesk-test-plugin.txt
sudo rm -rf 'D:\Temp\php\vylesk-test-plugin\vylesk-test-plugin.1.1\vylesk-test-plugin\'

The file and directory then deleted successfully (and I didn’t need an su password, which I don’t know anywhere because it’s in a virtual environment I don’t control).

Note 2 other elements of the commands:

  • In the first ‘rm’ line the “\\” (double-backslash), because backslashes need to be escaped.
  • In the second line I surrounded the directory path with single quotes, an alternative to the double-backslash.

Slow NBN or Fiber Internet? Check your modem/router and your WiFi band.

If you have Australia’s infamous NBN or other high speed internet service, but you find your service to be slow, then two things to check:

1. A poor quality modem/router can affect your speed. You may be getting 90Mbps into the router, but a bad router or too many connected devices will reduce the speed coming out of it into your phone/tablet/computer.

Here’s an example from my own experience.
I’ve been a customer of TPG’s FTTB (Fiber to the Building) network twice. The service consistently gives me speeds over 50Mbps and often nudges around 90Mbps.
When I initially setup the service (both times) TPG have be their own branded Huawei router.
In our first home it worked OK for a while and seemed to give good speeds (at least, compared to the ADSL2+ I previously had). We had 3 computers, 2 phones and an occasional tablet connected to it. After a while the Internet stopped and I suspect I literally burnt out the device. And devices would continually disconnect because we had too many connecting at the same time.

So I spent $300 (AUD) on a Netgear Nighthawk D7000 and saw immediate improvement.
We started nudging the theoretical max speeds, even over WiFi, with all devices connected. I could run 4 computers, 2 phones and a tablet at the same time, all over WiFi, with 2 computers streaming high quality video services and we never saw an interruption.

The same thing happened in our second home. We received a new modem, which I plugged in initially and tested. I was only getting ADSL2+ type speeds (about 12Mbps). I switched back to the Nighthawk and wham!, straight back to consistent 60-90Mbps over WiFi.

I’ve been running the Nigthawk and same number of connected devices (all on WiFi) for about 4 years now.
Occasionally I have to reboot the router. Very occasionally TPG has a service interruption. Apart from that, we regularly stream video services (free-to-air TV via web/YoutTube/Netflix/Amazon Prime) at the same time, over WiFi, during peak night time periods, and I never see a problem except in the service provider (usually the Australian free-to-air TV streaming sites).

2. It seems 2.4GHz vs 5GHz WiFi can affect your speed. That’s according to this article I found. The article starts:

A study of 43 devices conducted by Enex for the Australian Communications and Media Authority (ACMA) has “unexpectedly” shown 5GHz Wi-Fi outperforming 2.4GHz in long-range testing, negating a major reason to continue using the slower 2.4GHz band.

If your modem/router allows both bands, switch your connection up to the 5GHz band if you haven’t already. If you only have 1 WiFi choice then chances are you’re stuck with 2.4GHz.

[End of article]

In case you are interested

We need to remember “The Internet” isn’t just a solid pipe running from a website into your phone or computer.
There are many segments, devices and relays data must travel through to get from a website to your screen, each of which has it’s own limitations and factors that affect speeds.

Here’s just a few off the top of my head:

  • The server (computer) running the website or service:
    • CPU, memory and bus/network speeds affect the processing and speed of data.
    • Heat, both in and around the the server, affects the speed. In fact, heat can have a big affect on all electronics and computers.
    • Sometimes the server is under extreme load. Or the service is out.
    • Sometimes the data is “cached” (a copy is made) closer to you so time to get it to you is less. Sometimes the data comes from the other side of the world.
  • The transmission lines between the server and your Internet Service Provider. This can include:
    • Going up to space (to satellites) and back again.
    • Through undersea cables and crossing half the world.
    • Crossing through and being processed by tens of other servers as it moves across the world.
    • Some of these links around the world can be down, to the data has to be re-routed through other links.
    • Sometimes there is interference in the signal and quality is reduced.
    • Sometimes the Internet is “under attack” (being clogged up) by Denial of Service attacks that also affect your data.
    • Always there are many different segments that data must travel through.
  • In your Internet Service Provider.
    • They have filters and computers the data must travel through, checking for content restrictions and who knows what else.
  • From your Internet Service Provider to local phone exchange.
    • The quality of the transmission line (cables) will affect the speed.
  • From your local phone exchange to your home.
    • If you’re in Australia, the data could be travelling through anything from long-distance WiFi, to old copper cables or new fiber networks.
    • The distance from your exchange can affect speed because on older networks speed reduces the further away from the exchange you are.
    • In some networks (like old copper phone lines) the data also has to travel through curb-side switches before betting to your house.
  • In your home or building.
    • Phone line or fiber cabling inside your home will affect speed.
    • Physical lines can degrade or be damaged over time.
  • Into and through your modem.
    • Your modem will have different speed capabilities.
    • It will also have internal software and services that need to process your data.
  • From your modem to your device.
    • The quality and health of your cable from the modem to computer can affect speed.
    • If using WiFi, where you place the router and what the signal has to travel through (e.g. walls) to get to your device will affect speed.
  • Inside your device.
    • Your device will have different network components that have different speed and quality ratings.

And that process happens in both directions.
To get the data from a website your computer first sends a request to the site, going through all those same steps in the opposite direction.

Every step of the way, your data is being switched, processed, sped up or slowed down.
In the fraction of the second between a your device requesting data from a website or service and it being displayed to you, that data is been touched by hundreds or thousands of pieces of equipment and software.

(Note: In the above list refer to “data” as a singular – i.e. “data has”. I know this is wrong. I did it on purpose for the great good of reading.)

Cannot login to Nighthawk modem router admin page

I have a NETGEAR D7000 Nighthawk modem router and you can login to the admin screen via the IP or URL

The problem is, when I try to login on Chrome I get an error page “This page isn’t working – sent an invalid response” with “ERR_INVALID_HTTP_RESPONSE”:

The fix is easy:

Use the FireFox browser.

There must be something in the page that Chrome doesn’t like, bit FireFox is happy to load the page.

Predictable Links to Multiple GSuite/GMail Accounts

I run multiple personal and business domains with Google mail accounts.

I want to create links (both synced in Chrome bookmark bar and in a web page) to each mail account that I know will always take me to the account I want, even when accessing from different devices (I have a minimum of 2 primary laptop devices I login from regularly).

There is a URL schema Google uses to generated each logged-in account – e.g. (then increment the number for each inbox) – but if don’t login to each account in the exact same order on each device, then they get out of sync.


Today I found a solution.

To access the desired mailbox via a predictable URL, use the following template:

Change the to the actual email address.

This also works for emails in custom GSuite domains (e.g. my domain), because underneath all and GSuite domain emails redirect back to the same number based URL template I originally mentioned.

I also figured out the URL to link to a specific Google Calendar is:

Again, the URL will cause a redirect.


I’ve only tried these with accounts I’m already logged into. I’m not sure what happens on a new system where you haven’t logged in yet, but I expect they should still work just fine.



I originally performed a search for “link url to multiple gmail account” which lead to to answers at:


Update (same day): I somehow logged myself out of all Google accounts in Chrome while trying to re-establish a sync between computers. So mail account links I setup started going to the same Gmail account (the account I setup for the sync). But after logging back into each of my GMail/GSuite accounts all the links worked fine again, so I reckon that’s a validation the permalinks work.

Uninstall/remove Spotify on Windows 10

This is mainly a post for my own reference.

I had trouble uninstalling the Windows 10 Spotify application from an old system.

Going into Control Panel\Programs\Programs and Features and trying to uninstall simply wouldn’t do anything.

A quick search lead me to which had the answer.

Here are the steps you need to take:

  1. Open Windows Task Manager and kill the “Spotify Web Connector” process (It will be something like SpotifyWebConnector.exe or SpotifyWebHelper.exe – sorry, I forgot to note the exact name before writing this post, but it will be obvious in the process list).
  2. Disable your network/internet access (turn off/disconnect your wireless or pull out your network cable).

Now you should be able to uninstall Spotify. Just be patient give it a few seconds when you first try – there’s going to be a bit of a delay before the confirmation dialog comes up.

Don’t forget reconnect your internet access.

Microsoft All-in-One Media Keyboard: How to Print Screen

I have a backup “Microsoft All-in-One Media Keyboard” I need to use when my primary Ergonomic Wireless Desktop keyboard decides to die (possibly “concussion” induced at 11pm when technology decides to become my Nemesis).

The only problem is it does not come with a Print Screen button.

But thanks to some wonderful soul on the Interwebs we have an answer:

Print full screen: Fn + Windows Key + Space
Print current window: Fn + Alt + Space

Source: Microsoft Answers

Application window disappearing off edge of monitor (Windows 10)

In the last week I’ve had 2 instances of opening an application/program opening in Windows 10 and disappearing off the edge of one of my monitors.

My workstation is a HP OMEN gaming laptop with 2 attached monitors in a horizontal row. Unplugging monitors did not cause the hidden window to reappear.


The solution is reasonably simple.

1. Hold down the shift key and right-click on the application icon in the Windows task bar.

2. A context menu will appear. Select the “Move” option.

3. Immediately hold down the left mouse button. This will have the affect of selecting the title bar of the application and activating the ability to move that application’s window.

4. Still holding down your left mouse button (the primary button), move your mouse left and/or right and you should soon see your missing program window appear on the monitor.

(In both instances my application disappeared of the right side of my right-hand monitor. This may vary for different people.)

Copying from Excel adds quotes to pasted values

This is a problem that had me stumped for a moment today until I searched and found the answer.

I was using Excel string concatenation to generate SQL INSERT statements for a database import.
It was working fine until suddenly each cell I copied from Excel pasted with a double-quote (“) around the value.

The first answer to my Google search made we realise the problem: I’d added a line-break in the middle of my formula to help visualise my work while I was constructing the SQL.
It turns out when you add line breaks to cells in Excel, copied values are surrounded by quotes.

This actually makes sense when you think about it . Consider it in the context of working with CSV files – you need to distinguish between a line-break in a value and a new row/record in the file.
It just didn’t occur to me because now I’d never encountered it in this context.

Remove the line break and no more quotes are added to the copied values.


Alternate post title: ‘Excel: Copying cell with formula sometimes wraps value in double quotes (“)’

Add 2FA (2 Factor Authentication) for your Gmail and Google GSuite users

UPDATE (31 January 2019): This week I have switched across to Authy as my 2FA application of choice. The main reason being its backup capability, which gives me greater peace of mind if my phone ever dies (or needs to be changed).
Also, some of the top security people I follow use it too.


You really should be using 2 Factor Authentication (2FA or MFA) in your online accounts whenever it is available, especially if you re-use your passwords across accounts. Regardless, it’s a good extra layer of security to help protect your important assets.

I have a Gmail account and run 2 domains on Google’s GSuite.

For all Google’s greatness their documentation, like documentation of most large (and small) tech companies, is good but still hard to find and navigate through unless you know what you’re looking for (in fact most tech companies product zero to atrocious documentation in my humble opinion).


Here are 2 links to Google Support to help you get started with 2FA on your Google accounts:

  1. For domain administrators
    Set up 2-Step Verification for your domain:
  2. This is for individual users of the domain (i.e. email address holders) and GMail users.
    Turn on 2-Step Verification:
    The support page contains a link to which is where users actually get started.

With Google/GSuite accounts you can setup 2FA using: one or all of SMS, phone call, the Google Authenticator app (Play Store / iTunes), and downloadable one-time backup codes (store those in your password manager, like LastPass or 1Password. You have one of those, right?).

I particularly like the Google Authenticator Authy app.
Both Google Autneticator and Authy easy to use and integrate well with most services (e.g. Evernote, Dropbox and DigitalOcean).