Uploaded by Omar el amri

git bestPractice (1)

advertisement
GITLab
Best Practice
Guidelines & Naming Conventions
Branches
Knowledge is power as long as it is shared
2
Branching NamingConvention
Apart from the develop and master branches, what do we name our other branches?
<type>/<name>
│
│
│
└─⫸ name: Describes its purpose. Not capitalized. Max 50 characters.
│
└─⫸ type: The type of a branch must be clear in order to understand its purpose.
Knowledge is power as long as it is shared
3
Type
feature: add a new feature
bugfix : fixed a bug in pre-production
hotfix: fixed a critical bug in production
chore: code cleanup
Name
The name must be less than 50 characters.
The words must be lowercase and linked by hyphens “-” .
Knowledge is power as long as it is shared
4
Some examples:
feature/add-users-controller
feature/loader-style
hotfix/profile-page-error
chore/remove-deprecated-methode
bugfix/send-gateway
Knowledge is power as long as it is shared
5
Commit
Knowledge is power as long as it is shared
6
Commit Message Format
What is the easiet way to read commit history ?
<type>(<scope>): <short summary>
│
│
│
│
│
└─⫸ Summary in present tense. Not capitalized. No period at the end.
│
│
│
└─⫸ Commit Scope: (optional) file name, module name, function name, etc..
│
└─⫸ Commit Type: build|ci|docs|feat|fix|perf|refactor|test|chore|revert|style
Knowledge is power as long as it is shared
7
Commit Type
feat – a new feature is introduced with the changes
fix – a bug fix has occurred
chore – changes that do not relate to a fix or feature and don't modify src or test files (for example updating
dependencies)
refactor – refactored code that neither fixes a bug nor adds a feature
docs – updates to documentation such as a the README or other markdown files
style – changes that do not affect the meaning of the code, likely related to code formatting such as whitespace, missing semi-colons, and so on.
test – including new or correcting previous tests
perf – performance improvements
ci – continuous integration related
build – changes that affect the build system or external dependencies
revert – reverts a previous commit
Knowledge is power as long as it is shared
8
Scope
The scope should be the name of the file, module or function modified in the commit change.
Example: Login, release, addUser, styles.scss, etc..
Commit Message Body (Summary)
Use imperative, present tense: “change” not “changed” nor “changes”
Don't capitalize first letter
No dot (.) at the end
Knowledge is power as long as it is shared
9
Example of commit
To Do
fix(componentXY.ts): add missing parameter to function X. The error occurred because of <reasons>
chore(package.json): update @angular/material from version 12.3.5 to 13.2.4
build(release): bump version to 1.0.0
style(styles.scss): remove empty line
feat(feature/X): improve performance with lazy load implementation for images
Not To Do
Knowledge is power as long as it is shared
10
Rules for a great git commit message style
 Separate subject from body with a blank line
 Do not end the subject line with a period
 Capitalize the subject line and each paragraph
 Use the imperative mood in the subject line
 Wrap lines at 72 characters
 Use the body to explain what and why you have done something. In most cases, you can leave out details
about how a change has been made.
Knowledge is power as long as it is shared
11
Information in commit messages
 Describe why a change is being made.
 How does it address the issue?
 What effects does the patch have?
 Do not assume the reviewer understands what the original problem was.
 Do not assume the code is self-evident/self-documenting.
 Read the commit message to see if it hints at improved code structure.
 The first commit line is the most important.
 Describe any limitations of the current code.
 Do not include patch set-specific comments.
Knowledge is power as long as it is shared
12
Git Config
Knowledge is power as long as it is shared
13
Git configuration
• To set your Git configuration values such as name and email at the global level, you need to run the
following commands in the command prompt (cmd) :
 git config --global user.name "YourUsername"
 git config --global user.email "YourEmail"
 Example :
 git config --global user.name "hugo"
 git config --global user.email "hugo@etcinfo.fr"
• To verify that your configuration is correctly configured, you can run the following command:
 git config --list
PS: You can find your username on the Gitlab profile
Knowledge is power as long as it is shared
14
Readme
Knowledge is power as long as it is shared
15
Example of Readme.md (1)
Knowledge is power as long as it is shared
16
Example of Readme.md (2)
NB: I will send you the readme.md file in email.
Knowledge is power as long as it is shared
17
Knowledge is power as long as it is shared
18
Merci de votre
attention
Itgate Group
+216 36 200 483
contact@itgate-group.com
https://https://www.itgategroup.com/
19
Download