Set Up a Git Branch¶
This guide explains how to properly set up your local development environment and Git branch when starting work on a new feature or bugfix for Hyperledger Cacti. It also covers the expected directory structure and some common development commands.
Prerequisites¶
- Git installed on your local machine.
- A GitHub account.
- A fork of the Hyperledger Cacti repository.
Steps¶
- Clone your fork Clone your fork of the repository to your local machine.
- Setup your local fork
Add the upstream repository to keep your local fork up-to-date (optional but recommended).
# Add 'upstream' repo to list of remotes git remote add upstream https://github.com/hyperledger-cacti/cacti.git # Verify the new remote named 'upstream' git remote -v # Checkout your main branch and rebase to upstream. # Run those commands whenever you want to synchronize with the main branch git fetch upstream git checkout main git rebase upstream/main - Configure Windows longpaths (Windows only) If you are on Windows, ensure that long paths are enabled:
- Create your branch Checkout the main branch and create a new branch for your feature. Give it a simple, informative name.
- Checkout your branch and add/modify files Navigate to your new branch and begin development.
- Install git hook scripts Run the following command once to install the pre-commit hooks for secret detection.
- Familiarize yourself with the directory structure Follow the established directory structure when adding or modifying code:
docs/: Project documentation (MkDocs-based)docs/: Documentation source filesassets/: Static assets for documentation
examples/: Example applications and demosextensions/: Optional extensions and pluginspackages/: Core packages (monorepo structure)cactus-api-client/: API client utilitiescactus-cmd-api-server/: API server commandcactus-common/: Common utilities and shared codecactus-core/: Core framework functionalitycactus-core-api/: Core API definitionscacti-plugin-ledger-connector-*/: Ledger connector pluginscacti-plugin-keychain-*/: Keychain pluginscacti-plugin-satp-hermes/: SATP implementationcacti-test-*/: Test packages for integration testingcacti-copm-*/: COPM packagescacti-plugin-weaver-*/: Weaver integration plugins
tools/: Build and CI/CD toolingdocker/: Docker images (all-in-one ledger images)ci.sh: Main CI script
weaver/: Weaver interoperability framework-
whitepaper/: Project whitepaper -
Commit changes to your branch Use standard commands or Commitizen to commit your changes.
- Test locally Run the local CI script to verify your changes before submitting a PR.
- Open a Pull Request
Once you've committed and pushed all of your changes to GitHub, go to the page for your fork on GitHub, select your development branch, and click the "Pull Request" button. Repeat steps 4 to 10 when preparing a new pull request.
Note: Once you submitted a pull request to the Cacti repository, step 8 is not necessary if you make further changes with
git commit --amend, since your amends will be pushed automatically.
Expected Outcome¶
Your branch is successfully created, properly synchronized with upstream, code is modified following the standard directory structure, and your commits are pushed to your remote fork ready for a pull request.