| 1 |
# Git contribution workflow for ACI collection |
| 2 |
|
| 3 |
To contribute to the Cisco ACI Ansible Collection, follow the standard Git workflow: Fork → Clone → Branch. This ensures clean code isolation, proper tracking of changes, and allows seamless contributions via pull requests. Fork and clone tasks are carried out just once. |
| 4 |
The collection code is located in a git repository (https://github.com/CiscoDevNet/ansible-aci). |
| 5 |
|
| 6 |
**Step1: Fork the repository** |
| 7 |
|
| 8 |
A Fork is a personal copy of the repository under your GitHub account, allowing you to make changes without affecting the upstream project. |
| 9 |
|
| 10 |
Steps to create a fork of the repository: |
| 11 |
* Navigate to: https://github.com/CiscoDevNet/ansible-aci |
| 12 |
* Click the *Fork* button in the upper-right corner to create your fork of the CiscoDevNet's **ansible-aci** repo |
| 13 |
|
| 14 |
Refer to GitHub's official guide of [How to fork a repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) |
| 15 |
|
| 16 |
**Step2: Clone the forked repository** |
| 17 |
|
| 18 |
Clone allows to copy a repository to the local machine. |
| 19 |
|
| 20 |
* Clone the forked repository in the terminal using the following command: |
| 21 |
|
| 22 |
```text |
| 23 |
git clone https://github.com/<Forked Organization>/ansible-aci.git |
| 24 |
``` |
| 25 |
|
| 26 |
Verify the name of the Git remote of your forked repository by running the following commands in the terminal: |
| 27 |
|
| 28 |
```text |
| 29 |
cd ansible-aci |
| 30 |
git remote -v |
| 31 |
``` |
| 32 |
|
| 33 |
Expected output: |
| 34 |
|
| 35 |
```text |
| 36 |
origin https://github.com/<Forked Organization>/ansible-aci.git (fetch) |
| 37 |
origin https://github.com/<Forked Organization>/ansible-aci.git (push) |
| 38 |
``` |
| 39 |
|
| 40 |
**Naming Convention** |
| 41 |
"origin" is the default name for the first Git remote of a cloned repository. In this case, it represents your forked repo where you are going to make changes, commit, and push your code to GitHub. |
| 42 |
|
| 43 |
* Add the upstream repo as a new Git remote: |
| 44 |
|
| 45 |
To be able to retrieve the latest changes made to the upstream project repo (CiscoDevNet/ansible-aci), we need to add it as a second Git remote. We recommend calling this second remote "upstream" and we will keep referring to it as upstream in the rest of the document. |
| 46 |
Add the original CiscoDevNet repository (CiscoDevNet/ansible-aci) as a second remote named `upstream`, which will allow the fetch, and sync the latest changes: |
| 47 |
|
| 48 |
```text |
| 49 |
git remote add upstream https://github.com/CiscoDevNet/ansible-aci.git |
| 50 |
``` |
| 51 |
|
| 52 |
Adding the remote branch "upstream" is a one-time operation. |
| 53 |
After adding the upstream remote, update the local repository with the latest changes from the upstream repository: |
| 54 |
|
| 55 |
* Fetch and update the local `master` branch from upstream: |
| 56 |
|
| 57 |
```text |
| 58 |
git checkout master |
| 59 |
git pull upstream master |
| 60 |
``` |
| 61 |
|
| 62 |
**Step 3: Create a Feature Branch** |
| 63 |
|
| 64 |
Branch facilitates bug fixes, addition of new features, and the integration of new versions after isolated testing. Master is the default branch of the local repository. |
| 65 |
Each time changes are required for a module or a new module is to be created, it is recommended that a new dedicated branch be created from master. This provides a clean branch of the latest master, enabling all necessary modifications to be made. |
| 66 |
|
| 67 |
* Create a branch from master by using the following commands on the terminal: |
| 68 |
|
| 69 |
```text |
| 70 |
git checkout master |
| 71 |
git checkout -b <new-branch-name> |
| 72 |
``` |
| 73 |
|
| 74 |
Maintaining changes in a dedicated branch allows the master branch to remain clean and synchronized with the upstream master. This simplifies keeping the local master branch updated without the need to merge code or rebase the master branch. |
| 75 |
|
| 76 |
> [!CAUTION] |
| 77 |
> Never commit directly to `master`. Use feature branches for all development work to simplify merging, testing, and collaboration. |