Sync VSCode settings via Git repository

The problem

How to sync Visual Studio Code settings between different Linux devices.

The Solution

Versioning the Visual Studio Code~/.config/Code directory using GIT.

Tested enviroment

  • Ubuntu 18.04

The Code

As the current user:

cd ~/.config/Code
git init
cat > .gitignore << EOF
Cache
CachedData
CachedExtensions
GPUCache
logs
machineid
EOF
cat > update_and_push.sh << EOF
#!/bin/bash
code --list-extensions | xargs -L 1 echo code --install-extension >> install_extensions.sh
chmod 755 *.sh
DATE=`date +'%Y%m%d_%H%M'`
git add .
git commit -m "VSCode settings autocomit {$DATE}"
EOF
chmod 755 *.sh
git init
git add .
git commit -m "Initialize VSCode settings repository"
git remote add origin git@github.com:YOUR_USER/YOUR_REPOSITORY.git
git push origin master

On another computer, install Visual Studio Code and then run:

cd ~/.config
rm -rf Code/
git clone git@github.com:YOUR_USER/YOUR_REPOSITORY.git Code
install_extensions.sh

and everything is set.

Whenever you want to sync, run ~/.config/Code/update_and_push.sh to sync UP and cd ~/.config/Code; git pull origin master to sync DOWN on any devices.

Extra

If you're conmfortable with sharing on Github (unless you have a private account), Settings Sync can be your anwser.

Resources