Pushing Variables to GitLab Safely

git-vars package

Pushing Environment Variables Safely

git-vars push synchronizes the complete local file with GitLab. After confirmation, version 0.0.6 deletes every remote variable that is absent from the local file. Test this workflow only with a disposable project first. Never use an incomplete file.

Prerequisites

Create a fresh backup, review the complete local file, and compare both files before changing GitLab:

cd /path/to/your/repository
git-vars pull -s project -f ../ci-vars/project-before-push.env
diff -u ../ci-vars/project-before-push.env ../ci-vars/project.env

Keep both files outside the repository with permissions limited to your account. Confirm that the target is the intended disposable project and that project.env contains every variable that must remain.

Push Command

git-vars push -s project -f ../ci-vars/project.env

# -f --file: Path of the file to be pushed from

The output of this command would be something like this:

New Variables:
  <VARIABLE_NAME> = <VARIABLE_VALUE>

Updated Variables:
  <VARIABLE_NAME> --> OLD: <OLD_VALUE>, NEW: <NEW_VALUE>

Deleted Variables:
  <VARIABLE_NAME>

Do you want to apply these changes to GitLab? (yes/no):

Read the proposed new, updated, and deleted variables carefully. Answer no if any deletion or target is unexpected. After confirming the complete change set, git-vars reports each action:

ENV VARIABLE [ACTION] -> VARIABLE_NAME - success

Delete the plaintext exports securely when the review is complete. For production projects, prefer GitLab’s UI or a reviewed API-based workflow with an explicit backup and narrowly scoped change set.

Optional feedback