あじちゃんの備忘録。

〜ここはメモ帳です

開発の初期フォルダ設定 / Git の Local 設定

初期状態のmacに開発環境を構築する時、最初にプロジェクトを置くフォルダを作ると思います。その時のディレクトリ名とか諸々の設定のメモです。



ルートディレクトへ移動。ここに開発用フォルダを作ります。

$ cd ~

$ ls


Applications Documents Library Music Public
Desktop Downloads Movies Pictures

 

フォルダ名は htdocs にします。

私もよくわかってないのですが、ドキュメントルートを指すと思っていてHypertext Documentsの略でもあります。

(私がweb系の開発をする人間なので伝聞でこういう名前にしただけです...)

$ mkdir ~/htdocs

私の場合この下に、会社用と個人用でディレクトリをさらに分けますが考えないでいい人はこのまま進みます

 

考えないでいい人

  1. ディレクトリを移動します

$ cd htdocs

 

  1. Git を入れます

$ git init

 

  1. Git 設定を確認します

$ git config -l

core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true

多分こんな感じの出力がされると思います

 

  1. Global にユーザの設定を追加します

$ git config user.name {your user name}
$ git config user.email {your user mail}

 

  1. 設定を確認します

$ git config -l

core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
user.name={your user name}
user.email={your user mail}

多分こんな感じの出力がされると思います

user.name と user.email が指定したものになっていれば問題ありません

 

あとは、自分のGitリポジトリから諸々 clone するなりなんなりでOKです。

 

考えなきゃいけない人

  1. ディレクトリを移動します

$ cd htdocs

 

  1. ディレクトリを複数に分けます

$ mkdir SelfProject
$ mkdir WorkProject

 

  1. それぞれのディレクトリに Git を入れます

$ cd SelfProject

$ git init


$ cd WorkProject

$ git init

 

  1. それぞれのディレクトリでGit 設定を確認します

$ git config -l

core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true

多分こんな感じの出力がされると思います

 

  1. Local にユーザの設定を追加します  各ディレクトリで以下のように行います

$ git config --local user.name {your user name}
$ git config --local user.email {your user mail}

 

  1. ディレクトリで設定を確認します

$ git config -l


credential.helper=osxkeychain
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
user.name={your user name}
user.email={your user mail}

多分こんな感じの出力がされると思います

user.name と user.email がそれぞれ指定したものになっていれば問題ありません

 

  1. htdocs ディレクトリで Git 設定を確認します

$ git config -l


credential.helper=osxkeychain

こんな感じで、特定のユーザが指定されていなければOKです

あとは、各ディレクトリでそれぞれの Git リポジトリから諸々 clone するなりなんなりでOKです。



nodeをmacに入れる

homebrewをつかってnodeを入れることにします。

 

1. homebrewを入れる

https://brew.sh/index_ja

ここに書かれているスクリプトを実行します

 

2. nodebrewを入れる

$ brew install nodebrew

 

実行結果の最後に、こんな感じの出力がされればOK

==> Summary
🍺  /usr/local/Cellar/nodebrew/1.0.1: 8 files, 38.6KB, built in 3 seconds

 

バージョンの確認 1.0.1 が入ったことがわかります

$ nodebrew help
nodebrew 1.0.1

 

次はセットアップです

$ nodebrew setup

Fetching nodebrew...
Installed nodebrew in $HOME/.nodebrew

========================================
Export a path to nodebrew:

export PATH=$HOME/.nodebrew/current/bin:$PATH
========================================

 

指示通りに実行します

$ export PATH=$HOME/.nodebrew/current/bin:$PATH

export だけだとターミナルを落とすと初期化されちゃうので ~/.bash_profile にも設定を書くこと

# [.bash_profile]
export PATH=$PATH:$HOME/.nodebrew/current/bin

 

3. Node.js のインストール 

インストールできるバージョンの確認をするとき

$ nodebrew ls-all

 

私は、安定版を入れたいので

$ nodebrew install-binary stable


Fetching: https://nodejs.org/dist/v12.14.1/node-v12.14.1-darwin-x64.tar.gz

######################################################################## 100.0%

Installed successfully

 

入ったバージョンを確認します

$ nodebrew list
v12.14.1

 

安定版は v12.14.1 とわかったので、これを設定します

$ nodebrew use v12.14.1
use v12.14.1

 

現在のバージョンを確認します

$ node --version

v12.14.1

Currentが目的のバージョンなので完了です

もし、 node コマンドが使えなかったら大抵 setup を忘れていますね...