- Install Git: Make sure you have Git installed. To check, run:
git --version
Before working on the code base for the first time, clone the repository:
- Open your Terminal (e.g. Git Bash) or Command Prompt at the desired location or navigate to it using:
cd /path/to/your/projects-directory - Clone the repository using one of the following command:
Where
git clone <repository-url>
<repository-url>ishttps://github.com/SomeSourceCode/Kinote.gitfor HTTPS orgit@github.com:SomeSourceCode/Kinote.gitfor ssh. The URL can also be copied from the green Code button on the repository page. - Navigate into the cloned repository:
cd film-manager
The Branching Model is based on Git Flow.
We ensure that the main branch is always stable, while active development happens on the develop branch or dedicated feature/fix/... branches.
main(DO NOT PUSH HERE): this branch holds only stable code. New code is only added via pull requests.develop: This is where ongoing development happens. All new features or fixes are pushed or merged here.
If a new feature, refactor fix etc. is relatively small, it can safely be done directly on the develop branch.
For larger features etc. or if multiple people are working on the same code, a new branch should be created from develop.
Use hyphens to separate words in branch names.
- Feature Branches (new functionality):
- Naming Convention:
feature/short-description - Example:
feature/persistent-storage
- Naming Convention:
- Fix Branches (bug fixes):
- Naming Convention:
fix/short-description - Example:
fix/login-bug
- Naming Convention:
- ...
Summary: Use new branches for larger changes or when collaborating with others. For minor changes (typo, few lines of code), working directly on develop is acceptable.
Before writing any code, ensure you are on the develop branch and have the latest changes (IMPORTANT):
git checkout develop
git pull origin developCreate a new branch with a descriptive name, using the type/short-description pattern:
git checkout -b feature/my-new-feature- Stage your changes: Run the following command for each file you modified (note that you can stage whole directories too):
Try to group code changes logically when staging.
git add path/to/changed-file-or-directory # To stage all changes, use: git add .
- Commit your changes with a meaningful message:
For a more in-depth explanation/guides on writing good commit messages, see section 9.2.
git commit -m "feature: add persistent storage for user settings" - Push your branch to the remote repository:
git push origin feature/my-new-feature
For the first time that you push a new branch, you might need to set the upstream branch:
git push --set-upstream origin feature/my-new-feature
# Alternatively, shorter:
git push -u origin feature/my-new-featureFor all subsequent pushes, you can then just use:
git pushWhen two people change the same lines of a code on the same branch, a merge conflict might occur. We resolve them by rebasing. Rebasing is preferred over merging because it keeps the commit history linear and clean, making it easier to understand.
Merging adds a new "Merge Commit," which can clutter history. Rebasing takes your changes and moves them to the tip of the develop branch, making it look like you started your work after all recent changes were already made.
- First, commit your changes as described in section 4.1.
- Then, run the following command to rebase your commits onto the latest changes of the respective branch:
git pull --rebase origin <branch> # E.g. git pull --rebase origin feature/my-new-feature # or if you are working directly on develop git pull --rebase origin develop
- You might be lucky and have no conflicts. If so, just continue working as usual.
If there are conflicts, Git will pause the rebase and notify you about the files with conflicts.
- Open the conflicted files in your code editor.
- You will see markers like these:
<<<<<<< HEAD # Your changes ======= # Remote changes >>>>>>> [commit hash or branch name] - Decide how to resolve the conflict by choosing one side, combining changes, or rewriting the section. Make sure to also remove the conflict markers.
- Stage the resolved files:
git add path/to/resolved-file
- Continue the rebase process if there are more commits to be rebased:
git rebase --continue
- If there are more conflicts, repeat steps 1-5 until the rebase is complete.
Note: IntelliJ offers a user-friendly interface for resolving conflicts. You will see corresponding buttons when a rebase is in progress, assisting you with steps 2-5.
Before merging your feature/fix/... branch into develop, it's good practice to rebase it onto the latest develop branch to ensure a clean merge.
Skip this step if you worked directly on develop or are unsure.
When you feature/fix/etc. is complete and ready to be merged into develop, submit a Pull Request (PR) on GitHub.
- Go to the repository on GitHub and select the branch you want to merge into
develop. - GitHub will usually show a prompt to create a Pull Request. Click on it. If not, go to the "Pull Requests" tab and click "New Pull Request."
- Set the Base branch to
develop(IMPORTANT) and the Compare branch to your feature/fix/... branch. - Fill out the title and description fields:
- Provide a clear, descriptive title, e.g. "Implement persistent storage for user settings" or "Fix login bug causing crashes".
- In the description, explain what changes were made, why they were made, and any other relevant details.
- Depending on how major the changes are, request reviews from team members. You can assign the reviewers on the right side of the PR page or just ask via Discord.
- If changes are recommended during the review, make those changes in your local branch, commit, and push them. The PR will automatically update with the new commits.
- Finally, merge the branch into
developor let someone else do it.
After merging into develop, make sure to pull the merged changes into your local develop branch:
git checkout develop
git pull origin develop # Or just git pull if upstream is setThis section will be covered in the future.
If currently clean working directory (meaning no changes were made), it's sensible to always pull the latest changes the respective branch before starting new work:
git pullDoing this helps to avoid merge conflicts later on.
A good commit message should be concise yet descriptive enough to understand the changes made. You could use following pattern:
<type>(scope): <short-decsription>feat: New functionality addedfix: Bug fix or typo correctionstyle: Formatting, whitespace, missing semicolons, etc.docs: Documentation added or updatedchore: Maintenance tasks, e.g. updating README etc.build: Changes that affect the build system or external dependenciestest: Added modified test
The scope indicates which part of the codebase the commit affects. This is optional and could also be contained in the short description.
A brief summary of the changes made, written in the present tense.
If necessary, add a more detailed explanation of the changes in the body of the commit message.
To do so, use the git commit command without the -m flag, which will open your default text editor, then enter your commit message like so:
<type>(scope): <short-description>
↵
<detailed-explanation-of-the-changes>feat: add persistent storage for user settings
fix: correct typo in login error message
style: format code for better readability in UserService.java
docs: add documentation for media classes