Có một loạt các tùy chọn có thể được đặt qua git config
và đó là just the documented ones. Trong tất cả các tùy chọn này, những tùy chọn nào mà mọi nhà phát triển đã đặt trên hộp của họ (như user.email
)? Và những gì phổ biến nhất mà nên được đặt trong các tình huống phổ biến (như core.autocrlf=input
trên Windows)? Nhưng xin vui lòng tránh xa các lý lẽ tôn giáo (giống như thiết lập chỉ chấp nhận được của core.whitespace
là tab-in-indent
)Điều gì sẽ xảy ra trong tệp cấu hình git mặc định?
5
A
Trả lời
7
Cấu hình git chung (~/.gitconfig) của bạn nên chứa các cài đặt áp dụng cho TẤT CẢ kho lưu trữ của bạn. Chủ yếu là những thứ như user.name
, user.email
, core.editor
, merge
và diff
phải được thiết lập khá nhất quán. Điều đó đang được nói rằng tôi cũng muốn bật color
, core.pager
, rerere
, rebase.autosquash
và một loạt bí danh.
[color]
filemode = false
diff = auto
status = auto
branch = auto
pager = true
[alias]
b = branch
ci = commit
co = checkout
cob = checkout -b
d = diff
l = log
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
lga = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative --branches
st = status
fixup = !sh -c 'git commit -a -m \"fixup! $(git log -1 --format='%s' [email protected])\"' -
squash = !sh -c 'git commit -a -m \"squash! $(git log -1 --format='%s' [email protected])\"' -
ri = rebase --interactive
rc = rebase --continue
pr = push gerrit HEAD:refs/for/master
mt = mergetool
[user]
email = REDACTED
name = Matt Henkel
[core]
pager = less -FRSX
excludes = ~/.gitexcludes
editor = vim
[rerere]
enabled = true
autoupdate = true
[rebase]
autosquash = true
[merge]
tool = kdiff3
[mergetool "kdiff3"]
keepBackup = false
trustExitCode = false
[diff]
tool = kdiff3
1
Dưới đây là danh sách chú thích của một số cài đặt cấu hình phổ biến nhất. Tất nhiên, luồng công việc của môi trường/ngôn ngữ/os/git của tất cả mọi người là khác nhau, do đó bạn có thể sẽ phải tinh chỉnh điều này một chút nhưng đây là một số biến cấu hình phổ biến nhất.
[user]
# these are about the most basic and should pretty much always exist
email = [email protected]
name = Your Name
[core]
# if you use windows
#autocrlf = true
# use aggressive compression
# can make your repo smaller but can also be slow
compression = 9
# lets you define a global .gitignore for all those
# *.swp, *~, *.o, etc things that you're frequently
# sticking in .gitignore
excludesfile = ~/.gitignore_global
# tells git to ignore file permission changes
filemode = false
# lets you tweak the default pager
# see `man less` for the meaning of these flags
pager = 'less -FRSX'
# just because you said not to ;)
# probably not a good default for most projects,
# but you should set something here based on your needs
whitespace = tab-in-indent
[color]
# this turns on default colors for many commands
# or you can customize specific colors per command (see [3] for example)
ui = auto
[rerere]
# google `git rerere`, basically git remembers your
# partial merge choices and replays them next time
enabled = true
autoupdate = true
[push]
# let's you say just `git push origin` to push the current branch
default = current
[alias]
# this is the most subjective section
# aliases are useful if you either frequently typo certain words
# or else if you are used to another VC like cvs or svn
co = checkout
ci = commit
st = status
br = branch -av
brdel = branch -D
# Show all of my configured aliases
aliases = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\ \t => \\2/' | sort
# pretty much everybody has their favorite log format view
# you can find dozens of variations with a quick google
# here are couple of the most common (the first is my favorite)
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
trả lời được sáp nhập từ nhiều nguồn khác nhau:
Các vấn đề liên quan
- 1. điều gì sẽ xảy ra nếu php.ini bị thiếu?
- 2. Giá trị cấu hình git core.askpass mặc định là gì?
- 3. Điều gì sẽ xảy ra khi va chạm băm xảy ra trong khóa Từ điển?
- 4. Điều gì sẽ xảy ra khi tôi làm chủ gốc git pull trong nhánh phát triển?
- 5. Điều gì sẽ xảy ra khi gán cấu trúc mới cho mảng trong C#?
- 6. Nếu không xóa biến ThreadLocal, Điều gì sẽ xảy ra?
- 7. Sử dụng pin, điều gì sẽ xảy ra?
- 8. Điều gì sẽ xảy ra nếu phần đầu tiên của cấu trúc nếu là sai?
- 9. Điều gì sẽ xảy ra khi tôi biên dịch?
- 10. Điều gì sẽ xảy ra với AsyncTasks sau onPause?
- 11. Điều gì sẽ xảy ra sau khi gói bị bắt?
- 12. Điều gì sẽ xảy ra khi ném ngoại lệ C++?
- 13. Điều gì sẽ xảy ra nếu tôi ReleaseMutex() hai lần?
- 14. Điều gì sẽ xảy ra khi Stack và Heap Collide
- 15. Điều gì sẽ xảy ra khi mongodb hết bộ nhớ?
- 16. Điều gì sẽ xảy ra nếu hai tập lệnh python muốn viết trong cùng một tệp?
- 17. Điều gì sẽ xảy ra nếu xác định lại chức năng nội dòng?
- 18. Điều gì đã xảy ra với regtlibv12?
- 19. Điều gì đang xảy ra trong __libc_start_main?
- 20. Điều gì sẽ xảy ra nếu bạn biên dịch một tệp java rỗng?
- 21. Điều gì sẽ xảy ra nếu tôi không chỉ định targetFramework = "4.0"?
- 22. Điều gì sẽ xảy ra trong Git đối với thẻ khi bạn sửa đổi cam kết đã được gắn thẻ?
- 23. Điều gì sẽ xảy ra khi Java Compiler thấy nhiều chuỗi nối trong một dòng?
- 24. Điều gì sẽ xảy ra với con trỏ FILE sau khi tệp được đóng?
- 25. Đặt lại git proxy thành cấu hình mặc định
- 26. Trong Java, điều gì sẽ xảy ra nếu bạn sử dụng Double.NaN trong một hoạt động?
- 27. Điều gì sẽ xảy ra nếu giá trị tham số mặc định được xác định trong mã không hiển thị trên trang gọi?
- 28. Điều gì sẽ xảy ra trong một dịch vụ gián đoạn thường xuyên?
- 29. Điều gì sẽ xảy ra khi bạn đóng ứng dụng bảng điều khiển C++
- 30. Điều gì sẽ xảy ra nếu tôi không đóng cơ sở dữ liệu trong Android?
Thay vì một "chỉ cho tôi của bạn và tôi sẽ chỉ cho bạn của tôi "bạn có nghĩ rằng bạn có thể giải thích và biện minh cho mỗi mục? Nó có vẻ giống như một danh sách rất dài đầy đủ của personlaizations. Những cái nào nên đi vào cấu hình "mọi"? – shemnon
Mọi thứ, như trong mọi người, có lẽ chỉ là: user.name, user.email, core.editor, merge và diff. Tôi chỉ cần bao gồm cấu hình chung được chia sẻ chung của tôi để tham khảo. – Guildencrantz