-->

How to change git shell's start directory in w

2019-03-14 07:07发布

问题:

I downloaded and installed the programs offered by GitHub including Git Shell.

The problem is that I want to set up the home directory of the Git Shell program to a custom one, but I don't know how to do that.

I tried changing the "start in" field from the properties menu of the Git Shell shortcut but it didn't work.

Can anybody please give me some information on how to change the home directory of the Git Shell to a custom one?

回答1:

1.Open GitHub Windows client.

2.Click tools (at the top of the window) and select 'Options'.

3.There you will find 'default storage location'. This is where Git Shell starts when you run it.



回答2:

  1. Right click on Git Shell
  2. Choose Properties
  3. Move to the end of the Target field
  4. Change --open-shell to --open-shell=c:\your_dir


回答3:

When I use @ssmith's answer it opens up in the right directory but does not have any of the features of posh-git. When I open it up normally it say s posh-git in the title, when I add this configuration it just says powershell...

I figured it out, use/create the file

C:\Users\yourUserName\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

(the default profile) and then add the line mentioned above

Set-Location C:\Your\Start\Directory



回答4:

According the article below (in the "Posh-Git and PowerShell" section) you should be able to create a Documents\WindowsPowerShell\GitHub.PowerShell_profile.ps1 file that will start when your GitHub PowerShell starts. In that file you can add the Set-Location c:\path\to\repo command.

For what it's worth, in case anyone comes across this but has a Bash shell, adding the command cd /path/to/repo to ~/.basrc should do the trick.

http://haacked.com/archive/2012/05/21/introducing-github-for-windows.aspx



回答5:

Piotr Perak directions are accurate. however, for newer versions, you have to update the "Clone Path".


  1. Launch GitHub for windows.

  1. Click "Tools and Options" gear at top right > Options

  1. Change "Clone Path" to the directory you would like git to open at. Please see image below. Thank you.



回答6:

Other answers didn't work for me, and I am on Windows 10. So for those looking for another way I added a line to my ~/.bashrc: cd /c/myfoldername

Works like a charm