git #を構成する
概要#
個人の git 構成は.gitconfig、ホーム ディレクトリのファイルに保存されます。
.gitconfigファイルの例を次に示します。
[user]
name = Your Name
email = [email protected]
[alias]
ci = commit -a
co = checkout
st = status
stat = status
br = branch
wdiff = diff --color-words
[core]
editor = vim
[merge]
summary = true
コマンドを使用して、構成ファイルに既に含まれているものを確認できます。ファイルを直接編集するか、次の
コマンドを使用できます。git config --list.gitconfiggit config --global
git config --global user.name "Your Name"
git config --global user.email [email protected]
git config --global alias.ci "commit -a"
git config --global alias.co checkout
git config --global alias.st "status -a"
git config --global alias.stat "status -a"
git config --global alias.br branch
git config --global alias.wdiff "diff --color-words"
git config --global core.editor vim
git config --global merge.summary true
別のコンピューターでセットアップするには、~/.gitconfigファイルをコピーするか、上記のコマンドを実行します。
詳細に#
user.name と user.email #
コードに加えた変更にラベルを付けるために、自分が誰であるかをgitに伝えることをお勧めします。これを行う最も簡単な方法は、コマンド ラインからです。
git config --global user.name "Your Name"
git config --global user.email [email protected]
これにより、設定が git 構成ファイルに書き込まれます。このファイルには、名前と電子メールを含むユーザー セクションが含まれているはずです。
[user]
name = Your Name
email = [email protected]
と
を実際の名前とメール アドレスに置き換える必要があります。Your Nameyou@yourdomain.example.com
エイリアス#
一般的なコマンドにいくつかのエイリアスを使用すると、メリットが得られる場合があります。
たとえば、 に短縮できるようにしたい場合があり
ます。
または、(適切にフォーマットされた差分の出力を提供する)エイリアスを使用することもできます。git checkoutgit cogit diff --color-wordsgit wdiff
次のコマンド:git config --global
git config --global alias.ci "commit -a"
git config --global alias.co checkout
git config --global alias.st "status -a"
git config --global alias.stat "status -a"
git config --global alias.br branch
git config --global alias.wdiff "diff --color-words"
alias次のような内容のセクションが.gitconfigファイルに作成されます。
[alias]
ci = commit -a
co = checkout
st = status -a
stat = status -a
br = branch
wdiff = diff --color-words
編集者#
選択したエディターが使用されていることを確認することもできます
git config --global core.editor vim
マージ#
マージを行うときに要約を強制するには ( ~/.gitconfigfile を再度):
[merge]
log = true
またはコマンドラインから:
git config --global merge.log true
ファンシーログ出力#
これは、派手なログ出力を取得するための非常に優れたエイリアスです。ファイルのaliasセクションに移動する必要が
あります。.gitconfig
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)[%an]%Creset' --abbrev-commit --date=relative
エイリアスを次のように使用します。
git lg
そして、グラフ/テキスト出力を次のようにします(ただし、色付きです!):
* 6d8e1ee - (HEAD, origin/my-fancy-feature, my-fancy-feature) NF - a fancy file (45 minutes ago) [Matthew Brett]
* d304a73 - (origin/placeholder, placeholder) Merge pull request #48 from hhuuggoo/master (2 weeks ago) [Jonathan Terhorst]
|\
| * 4aff2a8 - fixed bug 35, and added a test in test_bugfixes (2 weeks ago) [Hugo]
|/
* a7ff2e5 - Added notes on discussion/proposal made during Data Array Summit. (2 weeks ago) [Corran Webster]
* 68f6752 - Initial implementation of AxisIndexer - uses 'index_by' which needs to be changed to a call on an Axes object - this is all very sketchy right now. (2 weeks ago) [Corr
* 376adbd - Merge pull request #46 from terhorst/master (2 weeks ago) [Jonathan Terhorst]
|\
| * b605216 - updated joshu example to current api (3 weeks ago) [Jonathan Terhorst]
| * 2e991e8 - add testing for outer ufunc (3 weeks ago) [Jonathan Terhorst]
| * 7beda5a - prevent axis from throwing an exception if testing equality with non-axis object (3 weeks ago) [Jonathan Terhorst]
| * 65af65e - convert unit testing code to assertions (3 weeks ago) [Jonathan Terhorst]
| * 956fbab - Merge remote-tracking branch 'upstream/master' (3 weeks ago) [Jonathan Terhorst]
| |\
| |/
投稿してくれた Yury V. Zaytsev に感謝します。