Skip to content

Cách viết commit có body #10

@Achicken7301

Description

@Achicken7301

Bình thường viết sẽ git add những file mình cần commit xong sau đó viết một tiêu đề.

git add static/admin/file1.php file2.php file3.html
git commit -m "Add file1 file2 file3"

Để thêm thông tin commit như thế này thì ta cần code như sau:
Đầu tiên ta cần chỉnh lại text-editor (nano, vim, emacs, notepad, vscode, sublime-text, atoms,...)

git config --global core.editor nano

Với nano là loại text-editor muốn sử dụng.

Sau đó git add các file cần thiết rồi nhập git commit thì nó hiện ra trông như thế này
image

Rồi nhập 50 kí tự đầu là tiêu đề, CÁCH 1 DÒNG, nhập body.
VD:

Đây là tiêu đề commit

Đây là body

Xong nhớ save lại thoát ra là xong.
Khi sử dụng nano thì Ctrl + X > Y > enter
Nguồn

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions