LoginSignup
1
3

More than 3 years have passed since last update.

git bash起動時のカレントディレクトリディレクトリの設定・ホームディレクトリの設定

Posted at

環境

  • windows10
  • gitbash

git bashの起動時のディレクトリ

目標「2の状態を1にしたい」

1
ユーザ名@DESKTOP-**** MINGW64 ~
$ pwd
/c/Users/ユーザ名
2
ユーザ名@DESKTOP-**** MINGW64 /
$ pwd
/

2の場合

タスクバーにショートカットがある時

1.エクスプローラーにおいてショートカット一覧のディレクトリへいく。

path
C:\Users\ユーザ名\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar

にショートカットがあるのでここにあるGitBahのプロパティを開く。

2.プロパティからリンク先を変更する。

リンク先
"C:\Program Files\Git\git-bash.exe" --cd-to-home

// --cd-to-homeを消す
"C:\Program Files\Git\git-bash.exe" 

3.作業ファルダのパスを書き換えるまたは付け足す。

作業フォルダー
%HOMEDRIVE%%HOMEPATH%

タスクバーにショートカットがない時

1.まずどこでもいいのでショートカットを作成して、エクスプローラーの作成した場所へいく。
2.タスクバーにショートカットがある時の2以降と同様に従う

Git bashのホームディレクトリを変更する

gitbash
$ cd ~
$ pwd
/c/Users/ユーザ名



更に場所を指定する方法
(例)初期カレントディレクトリをDesktopにする

gitbash
$ setx HOME "C:\Users\ユーザ名\desktop"

$ cd ~
$ pwd
/c/Users/ユーザ名/desktop
1
3
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
1
3