Version control with Git
Keep your anfra project in GitHub, GitLab or any Git host, and publish from it
An anfra project is a folder of plain files: data models and datasets in .aml, data apps in apps/. Because everything is code, you can keep it in Git and host it on GitHub, GitLab, Bitbucket or any Git server. Your team reviews changes to metrics and apps in pull requests, the same way it reviews application code.
What to commit
Commit your .aml files, apps/ and the .anfra/ folder, including .anfra/config.yml, which sets the organization anfra publish sends to.
As a best practice, leave out .anfra/data_sources.yml, since it holds your warehouse credentials. The .gitignore that anfra init creates ignores it. Commit .anfra/data_sources.yml.example instead, so teammates who clone the repo know what to fill in. See Project structure.
Publish from your repo
With Git, the repository is where your team shares its work, and you publish it to your organization on anfra BI Cloud. Treat one branch, usually main, as what's live. Work on a branch, merge it through your usual review, then publish from an up-to-date main:
git switch -c my-change
# ... work, then merge my-change into main through your usual review ...
git switch main
git pull
anfra publishWhat your teammates published came from main too, so it's already in your checkout and the publish goes through.
A publish sends the files as they are in your folder, committed or not. anfra publish and anfra publish check warn, without stopping, when you're on another branch or have unpushed commits or uncommitted files. The publish message defaults to the latest commit's message, so the organization's history matches your Git log. See Publish to anfra BI.
Two habits keep anfra BI Cloud in step with main:
- Don't publish from another branch. The organization then has that branch's files, and a teammate's next publish from
mainstops and asks them to runanfra pull. - Commit before you run
anfra pull, sogit diffshows only what the pull changed.
When a publish asks you to pull
If someone published something that isn't in main, such as from another branch or without pushing, anfra publish stops with pull_required. Bring their changes into a branch with anfra pull, merge it into main the way your team reviews changes, then publish:
git switch main
git pull
git switch -c pull-published
anfra pull
# ... resolve any conflicts, commit, and merge pull-published into main ...
git switch main
git pull
anfra publishIf you run anfra pull with uncommitted changes, it warns you. anfra pull --abort undoes the pull, but also loses edits you made since to the files it changed. See Resolve conflicts.
Join an existing project
Clone the repository, then run anfra init --yes in it. It adds what isn't committed without overwriting your files. It creates .anfra/data_sources.yml as a copy of the committed .anfra/data_sources.yml.example, so add your own credentials there. The organization's address is already in .anfra/config.yml, so you don't need --set-org.
Your first anfra publish or anfra pull checks that the clone matches what's published, and records it. If a file differs, a pull gives it conflict markers, since anfra can't tell which side changed it. git log -- <path> helps you decide which version to keep. See Resolve conflicts.
Publishing from CI
anfra auth login needs a browser, so publishing from a CI runner such as GitHub Actions or GitLab CI isn't supported yet.