Monday, December 18, 2017

Ubuntu remove error repository from apt update

When you add a repository URL that doesn't work and later when you do 'sudo apt-get update' and it starts throwing errors; use the below command to remove it.

sudo add-apt-repository --remove <url>

Replace the <url> with error repo URL.

Ex: sudo add-apt-repository --remove http://ppa.launchpad.net/ondrej/mysql-5.6/ubuntu

Happy Coding!

Wednesday, December 13, 2017

Github clone only a sub-directory of a repository

If there is a need to download only a sub-directory of the full Github repo, you can do the following steps to clone the required directory.

  • git clone <repo root url> <name of the sub-directory>
  • cd <name of sub-directory>
  • git filter-branch --prune-empty --subdirectory-filter <path to sub-directory> HEAD 
Ex: Let's say you need to clone the apim-is-as-keymanager-sso directory from https://github.com/wso2/presales-demos GitHub repo. Execute the following commands.
  • git clone https://github.com/wso2/presales-demos apim-is-as-keymanager-sso
  • cd apim-is-as-keymanager-sso
  • git filter-branch --prune-empty --subdirectory-filter apim-is-as-keymanager-sso HEAD 
Happy Coding!