Project: Botkube (Observability and Analysis / Observability)
File: git-workflow.md

This document describes the best practices when working with Botkube repositories. Each contributor and maintainer must follow this workflow: Work on forked repositories. Create branches on the fork and avoid working directly on the `main` branch. A fork is a copy of the repository from which you raise pull requests to propose changes to the original repository. The contribution workflow that bases on forks allows both the members of the Botkube repositories, and the external contributors to contribute code and content through the same process. This keeps the main repositories clean as contributors create branches only on the forked repositories. To create the fork, click Fork button in the upper-right corner of the repository's main page. Note The document refers to the original repository as the `upstream` repository and to the forked repository as the `origin` repository. To make it easy to synchronize the changes from the upstream repository, configure a new Git `remote` and set the synchronization of the `main` branch to the new `remote`. Clone the fork to your local machine. Use the Code button on the repository's main page to view the command to use. Navigate to the location of the cloned repository. To see the current configured remote repositories, run the following command: ```bash git remote -v ``` The result has the following format: ```bash origin https://github.com/{your-username}/{repository}.git (fetch) origin https://github.com/{your-username}/{repository}.git (push) ``` Specify a new remote upstream repository to synchronize with the fork: ```bash git remote add upstream git@github.com:kubeshop/botkube.git ``` Disable pushing changes directly to the upstream: ```bash git remote set-url --push upstream no_push ``` Fetch all remote branches: ```bash git fetch --all ``` Set the local `main` branch to track the remote `main` branch from the upstream repository: ```bash git branch -u upstream/main main ``` From now on, every time you pull the changes from `main` branch on the local repository, you refer to the `main` branch of the upstream repository. After you set up your fork, start contributing. Follow these steps: Check out the `main` branch. ```bash git checkout main ``` Pull the latest changes: ```bash git pull ``` Create a new branch: ```bash git checkout -b {branch-name} ``` Change proper files according to what you want to contribute. Select changes to commit. To include all changes you made within the repository, use: ```bash git add -A ``` Commit changes: ```bash git commit -m "{your message}" ``` Push changes to the origin repository: ```bash git push -u origin {branch-name} ``` Open a pull request from GitHub UI or CLI. For the pull request title, use the following rules: Include a short description of changes made. Use the imperative mood. Capitalize it. Do not end the subject line with a period. For the pull request description, adhere to the pull request template. To keep the branch up to date, execute the set of following commands: ```bash git pull upstream main:main git rebase main ``` In case of any conflicts during the rebase, run: ```bash git rebase --abort ``` Follow the chapter from the "Pro Git" book to squash your commits into one. Retry the rebase, resolve all conflicts and continue the rebase with the command: ```bash git rebase --continue ```