The Google Drive Push CLI is a tool for syncing files between a local directory and Google Drive. It supports pushing and pulling files, managing remote items, and displaying differences between local and remote files.
Before you can use the tool, you'll need to enable the Google Drive API and set up OAuth 2.0 credentials. Follow these steps to set it up:
- Go to the Google Cloud Console.
- Create a new project.
- Enable the Google Drive API for your project:
- Navigate to APIs & Services > Library.
- Search for "Google Drive API" and enable it.
- Create OAuth 2.0 credentials:
- Go to APIs & Services > Credentials.
- Click Create Credentials > OAuth Client ID.
- Choose Desktop App as the application type.
- Download the
credentials.jsonfile and save it to the configuration directory:- Linux:
$XDG_CONFIG_HOME/goop-cli, or~/.config/goop-cli - Windows:
%APPDATA%\goop-cli
- Linux:
Run goop config --path to print the exact configuration file location on your machine. Set GOOP_CONFIG_HOME to override the configuration directory entirely.
Releases are published for both x86-64 and ARM64 Linux. Pick the asset that matches your machine:
# x86-64
curl -fL -o /tmp/goop https://github.com/yojoecapital/goop-cli/releases/latest/download/goop-linux-x64 && chmod 755 /tmp/goop && sudo mv /tmp/goop /usr/local/bin/goop
# ARM64 (Raspberry Pi, Ampere, ARM servers)
curl -fL -o /tmp/goop https://github.com/yojoecapital/goop-cli/releases/latest/download/goop-linux-arm64 && chmod 755 /tmp/goop && sudo mv /tmp/goop /usr/local/bin/goopTo detect your architecture automatically:
case "$(uname -m)" in
x86_64) asset=goop-linux-x64 ;;
aarch64) asset=goop-linux-arm64 ;;
*) asset="" ;;
esac
if [ -z "$asset" ]; then
echo "unsupported architecture: $(uname -m)"
else
curl -fL -o /tmp/goop "https://github.com/yojoecapital/goop-cli/releases/latest/download/$asset" && chmod 755 /tmp/goop && sudo mv /tmp/goop /usr/local/bin/goop
fiBefore 3.2.0 the release published a single asset named
goop. It is now published per architecture, so older install commands pointing at.../download/goopwill no longer resolve.
Run the following command to see all available options and commands:
goop --help-
initialize <remote-path>(orinit): set up a new sync folder by creating a.goopfile in the current directory- use
--depth <depth>to set the maximum folder depth to sync - if the
<remote-path>argument is omitted, an interactive prompt will allow users to traverse their Google Drive directories in the terminal and select the folder to sync
- use
-
status(orst): show the sync folder's local directory, remote folder, depth, cache state, and ignore file -
push: upload local changes to the associated Google Drive folder- use
--operations [c|u|d](or-x) to specify which operations should be pushed. Thecstands for create,ufor update, anddfor delete. The default value for this iscudfor all the operations - use
--ignore <glob-pattern>(or-i) to ignore additional glob patterns from being processed - use
--yes(or-y) to skip the confirmation prompt
- use
-
pull: download remote changes from Google Drive to the local directory- the same arguments in
pushare present inpull
- the same arguments in
-
diff: display the differences between the last modified times of local and remote files -
config: print the current configuration- use
--pathto print the configuration file's location - use
--edit(or-e) to open it in$VISUAL/$EDITOR - use
--resetto restore the defaults
- use
-
completions <bash|zsh|fish>: generate a shell completion script -
version: print the version -
clear-cache: delete the local cache database
You can manage remote items with the remote command. If you omit the <path> argument, an interactive prompt will be used instead.
remote info <path>(orremote information): get information for a remote itemremote list <path>(orremote ls): list items in a remote folder (default is/)remote mkdir <path>: create a new folder in an existing remote folderremote move <path>(orremote mv,remote rename): move and/or rename an item- use
--into <remote-path>to reparent the item - use
--name <name>(or-n) to rename it; passing only--namerenames in place
- use
remote copy <path>(orremote cp): copy an item into a remote folder- use
--into <remote-path>to choose the destination and--nameto name the copy - folders are copied recursively up to
--depth
- use
remote trash <path>(orremote rm): move an item to the trash- use
--listto list the items currently in the trash - use
--emptyto permanently delete everything in the trash - use
--yes(or-y) to skip the confirmation prompt
- use
remote restore <name>(orremote untrash): restore an item from the trashremote download <path>: download a remote itemremote upload <local-path>(orremote up): upload a local file or folder into a remote folder- use
--into <remote-path>to choose the destination folder
- use
# bash
goop completions bash | sudo tee /etc/bash_completion.d/goop > /dev/null
# zsh
goop completions zsh > "${fpath[1]}/_goop"
# fish
goop completions fish > ~/.config/fish/completions/goop.fishThe program stores a cache under the configuration directory as cache.db, which can be deleted (or cleared with goop clear-cache) to reset the cache. Configuration options live alongside it in config.json.
Here is an example of the configuration file:
{
"cache": {
"ttl": 300000,
"enabled": true
},
"auth": {
"max_token_retries": 3,
"retry_delay": 1000
},
"auto_ignore_list": [
".goop",
".goopignore"
],
"default_depth": 3,
"max_depth": 3
}| Key | Meaning |
|---|---|
cache.ttl |
Cache lifetime in milliseconds |
cache.enabled |
Whether remote metadata is cached locally |
auth.max_token_retries |
Maximum number of token refresh attempts |
auth.retry_delay |
Delay in milliseconds between token refresh attempts |
auto_ignore_list |
Patterns always ignored during sync |
default_depth |
Default sync folder depth |
max_depth |
Maximum sync folder depth |
Comments and trailing commas are tolerated when the configuration file is read, so annotating it by hand is safe.
Create a .goopignore file inside a sync folder and use it to specify a list of glob patterns that should be ignored. Blank lines and lines starting with # are skipped, and a leading ! negates a pattern.
# secrets
secret-file.txt
secret-items/**
Build the project as a self-contained, single-file executable. The repository uses a git submodule, so clone with --recurse-submodules (or run git submodule update --init --recursive in an existing clone).
cd GoogleDrivePushCli
dotnet publish -c Release -r linux-x64 --self-contained true /p:PublishSingleFile=true
dotnet publish -c Release -r linux-arm64 --self-contained true /p:PublishSingleFile=trueSupported runtime identifiers are linux-x64, linux-arm64, win-x64, win-arm64, osx-x64, and osx-arm64. Omitting -r builds for the host machine's own architecture.
Release binaries for linux-x64 and linux-arm64 are built and attached to a GitHub release automatically by .github/workflows/release.yml when a tag is pushed.