LoginSignup
0
0

More than 1 year has passed since last update.

gitの基本的な操作

Last updated at Posted at 2022-05-25

Gitを設定する

git config

Gitの設定ファイルにある変数の値を設定する。
設定ファイルの変数には3種類ある。

gitの設定ファイル(の種類

そのマシン全体に対する設定

etc/gitconfig

ユーザーごとの設定

~/.gitconfig

プロジェクトごとの設定

.git/config

思ったこと

ファイルの種類で設定が変わる。

これらのファイルの設定を変えるためにはオプション引数が必要となる。

オプション引数

--global

~/.gitconfigの設定(ユーザーごとの設定)を変えることができる。

--system

/etc/gitconfigの設定(そのマシン全体の設定)を変えることができる。

オプション引数なし

.git/configの設定(プロジェクトごとの設定)を変更できる。

Gitを始める前にする設定

ユーザーごとの設定(~/.gitconfig)名前とメールアドレスは設定すると良い

git config --global user.name "hogehoge"
git config --global user.email "hogehoge@hogehoge"

また自分が普段使っているエディタ、画面表示の色を指定する。

git config --global core.editor emacs
git config --global color.ui auto

この場合エディタはemacs、画面表示の色は何かしらした。
しかし
画面表示に色がついて見やすいらしい。

演習

git config --globalを使って名前とメールアドレスを設定しよう

**********@mbp training % git config --global user.name "*******"
+******@mbp training % git config --global user.email "****************"

git config --globalを使って、普段使っているエディタを設定しよう。

***********@mbp training % git config --global core.editor ******
************@mbp training % git config --global color.ui auto

git config --global -lを使って正しく設定されたかを確認する。

**********@mbp training % git config --global -l
user.name=*****
user.email=*********************
init.defaultbranch=*******
core.excludesfile=/Users/**********/.gitignore_global
core.editor=**********
difftool.sourcetree.cmd=***************
difftool.sourcetree.path=
mergetool.sourcetree.cmd=***************
mergetool.sourcetree.trustexitcode=********
color.ui=auto

なんだかわからないが設定されたらしい。

出典 わかるGIT(福永 和人著)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0