DEV Community

Long Nguyễn Xuân
Long Nguyễn Xuân

Posted on

Thiết lập user.name, user.email cho riêng 1 repo / global

git cũng giống như các ứng dụng nguồn gốc UNIX/LINUX khác, hỗ trợ rất nhiều config value, 2 trong số đó là user.nameuser.email, 2 field này giúp "ghi dấu" tên tác giả của commit tương ứng.

khi cài đặt git lần đầu tiên, git sẽ lấy thông tin username & hostname của hệ thống để set vào user.nameuser.email, điều này để đảm bảo rằng mỗi commit luôn luôn dc "đánh dấu tác giả" đầy đủ.

vấn đề là khi đó lịch sử nó sẽ chứa các tên "không chuyên nghiệp" như thế này

Image description

với các dự án nguồn mở thì không sao, ghi dấu ấn cá nhân cũng tốt, nhưng với dự án của doanh nghiệp, thì không nên.

vậy nên, nếu bạn dùng laptop/PC công ty để làm việc, vui lòng thiết lập lại user.nameuser.email ở cấp độ global

$ git config --global user.name "{WORK_ACCOUNT}"
$ git config --global user.email "{WORK_EMAIL}"

# ví dụ 

$ git config --global user.name "longnx"
$ git config --global user.email "longnx@example.com"

Enter fullscreen mode Exit fullscreen mode

nếu dùng laptop cá nhân, hoặc cùng lúc làm cho nhiều công ty khác nhau thì có thể setting nó ở cấp độ local bằng việc không sử dụng cờ --global

$ git config user.name "{WORK_ACCOUNT}"
$ git config user.email "{WORK_EMAIL}"

# ví dụ 

$ git config user.name "longnx"
$ git config user.email "longnx@contoso.com"

Enter fullscreen mode Exit fullscreen mode

Thông tin thêm

Trong git, có 3 cấp độ config value theo thứ tự ưu tiên là local > global > system, chi tiết có thể tìm hiểu thêm ở đây.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay