How to git

This tutorial will describe the current git based workflow that is followed during the MARCH code development.

Prerequisites

Before following the following steps make sure you:

  • Have git installed on your device.

  • Have git LFS (Large File Storage) installed on your device.

  • Have your git config setup.

    • git config --global user.name "[Your name]"

    • git config --global user.email "[Your email]"

  • Have cloned the march repo.

    • git clone https://gitlab.com/project-march/march.git --recurse-submodules

Roadmap for adding something to the repository

  1. Create an issue on gitlab.
    1. Go to issues on the gitlab page (https://gitlab.com/project-march/march/-/issues)

    2. Press the blue button with “New issue”.

    3. Give a clear title.

    4. Choose a template for description.

    5. Fill in the rest of the description.

    6. Assign it to yourself

    7. Add the relevant titles

    8. Press the blue button at the bottom with “Create issue”.

  2. Create a branch via the issue
    1. Press the arrow in the blue button “Create merge request”.

    2. Select “Create branch”.

    3. (Optional) Select a different Source branch. Keep it on “dev” if you are unsure.

  3. Fetch the new repo data in your cloned folder.
    1. Open a terminal with git installed.

    2. cd to the cloned “march” folder.

    3. Type git fetch.

  4. Checkout/switch to your new branch
    • git checkout [issue_number]-[issue_name] (e.g. git checkout 1103-fix-docs-bug)

    • git switch [issue_number]-[issue_name] (e.g. git switch 1103-fix-docs-bug)

  5. Start adding code. #code_knallen

  6. Commit your code.

    Note: Make sure your code is still runnable after every commit. If this is not the case for some reason make sure you add “draft:” at the start of your commit message.

    1. Type git status to see which files have changed.

    2. Type git add [changed files you wish to commit]

    3. Type git status again to check if all the correct files are staged.

    4. Type git commit -m "[Commit message]"

    Note: The commit message should be active form and should follow from: “This commit will [Commit message].

  7. Push all your commit
    1. Type git push.

  8. Create a merge request via gitlab
    1. Go to the merge requests page. (https://gitlab.com/project-march/march/-/merge_requests)

    2. Select the blue button “New merge request”.

    3. Select as source branch your branch that you where working from

    4. By default keep dev as target branch.

    5. Press the blue button “Compare branches and continue”.

    6. Write a detailed overview of what this commit does.

    7. Assign at least 2 reviewers,
      • One (or more) of the software architects.

      • Someone from semi-software that has knowledge of the issue.

    8. (Default) Leave “Delete source branch when merge request is accepted.” checked.

      Only uncheck this one if you wish to keep working on the feature.

    9. (Default) Leave “Squash commits when merge request is accepted.” unchecked.

      Only check this one if the branch has an ugly commit history.

  9. Check if the pipeline succeeds, otherwise fix those issues.

    This can be found on:

    • The CI/CD tab on gitlab.

    • The merge request page.

  10. Check for merge conflicts. If there are any, resolve those.

  11. Wait for the MR (merge request) to be reviewed and merged. :)