8

I have been struggling to change .ssh location on git bash.

When I open Git Bash command prompt, I'm typing cd ~/.ssh then my Git Bash navigates to some H:/xyz/.ssh directory. I want to change it to some D:/user/.ssh directory. Sorry, I'm not experienced on UNIX but tried some ways found on internet in vain. Please advise.

IndoKnight
  • 1,766
  • 1
  • 19
  • 29
  • 1
    which version (OS and GitBash) are you using? On Windows7 with version 1.8.1.2-preview20130201 i am in my /c/Users/ folder after typing "cd ~/.ssh" – x29a Sep 09 '13 at 16:33
  • 1
    Thanks for your reply. I'm on Windows XP and GitBash version 1.8.3 preview20130601. – IndoKnight Sep 09 '13 at 16:43
  • 1
    what does "echo $HOME" output? Is your home folder on some network share (H:) maybe? Company policy? Just tried with version 1.8.3-preview20130601 and it correctly goes into $HOME/.ssh – x29a Sep 09 '13 at 16:48
  • Spot on! It is set to H:/xyz. How can I change this to elsewhere? – IndoKnight Sep 09 '13 at 16:53

1 Answers1

7

In order to change your HOME variable (containing the path to your home directory) you can try different approaches.

The linux "inhouse" solution would be to edit your ~/.bashrc file (or create it) to say something like

export HOME="/d/user"

Next time you start GitBash, and type

cd ~/.ssh

it will go into /d/user/.ssh if the directory exists.

Now according to danlimerick and GregK you can also set the HOME variable directly in Windows. The links also mention how you can change the startup folder via changing the shortcut properties.

Similar questions with answers can be found here and here.

Community
  • 1
  • 1
x29a
  • 1,633
  • 1
  • 21
  • 39