2011-06-29 14 views
5

git config aracılığıyla ayarlanabilen ve just the documented ones olan şaşılacak bir dizi seçenek vardır. Bu seçeneklerin hepsinden hangisi her geliştiricinin kendi kutusuna koyduğu (user.email gibi)? Ve ortak durumlarda ayarlanması gereken en yaygın olanlar nelerdir (Windows'ta core.autocrlf=input gibi)? Ama lütfen dini argümanlardan uzak durun (core.whitespace'un tab-in-indent olduğu kabul edilen tek ayar gibi)Varsayılan git yapılandırma dosyasında ne gitmeli?

cevap

7

Genel git yapılandırmanız (~/.gitconfig) gerçekten tüm depolarınız için geçerli olan ayarları içermelidir. Öncelikli olarak, user.email, core.editor, merge ve diff gibi şeyler tutarlı bir şekilde ayarlanmış olmalıdır. Aynı zamanda, color, core.pager, rerere, rebase.autosquash ve bir takım takma adların etkinleştirilmesini istediğim söyleniyor.

[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 
+8

bir "sen göster ve ben göstereceğiz:

[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 

Cevap birçok kaynaktan birleştirildi sen benim "her bir öğeyi açıklayabileceğini ve haklı çıkarabileceğini düşünüyor musun? Kişilerle dolu çok uzun bir liste gibi görünüyor. Hangileri "her" yapılandırmaya girmeli? – shemnon

+0

Herkes, herkes için olduğu gibi, muhtemelen sadece: user.name, user.email, core.editor, birleştirme ve farklıdır. Referans için ortak paylaşımlı genel yapılandırmamı eklemiştim. – Guildencrantz

1

Aşağıda, en yaygın yapılandırma ayarlarından birkaçının açıklamalı bir listesi verilmiştir. Tabii ki, herkesin ortam/dil/os/git iş akışı farklıdır, bu yüzden bunu biraz düzeltmeniz gerekecek, ancak bunlar en yaygın yapılandırma değişkenlerinden bazılarıdır.

  1. http://githowto.com/aliases
  2. http://www.javacodegeeks.com/2013/06/git-configuration-options-you-cant-miss.html
  3. http://michaelwales.com/articles/make-gitconfig-work-for-you/
  4. yerine
  5. http://wildlyinaccurate.com/useful-git-configuration-items/
İlgili konular