I'm still learning Git and GitHub and I haven't been able to figure this out so far. I found a public repository on GitHub that I wanted to try editing, so I forked the repository and then cloned it so I'd have a local copy of the files to work with. I had to search for a while online to figure out where exactly Git puts the local files, but I ended up finding the files in their respective subfolders under C:\Users\\Documents\GitHub (I have Windows 7 -- for other versions of Windows the files are apparently in C:\Documents and Settings\< current_user>).
When setting up GitHub I was able to select a repository location, but apparently that location only affects repositories I create, not repositories I clone. I wanted to try and figure out a way to change the default cloned directory location, but it sounds like the only way to do this is to change the HOME environment variable. However, changing an environment variable that could also affect other programs does not sound like best practice so I'm hoping there's another way.
I found one way to do this by simply specifying the desired path every time I enter a clone command, like this:
git clone https://github.com/username/example.git c:/other/path/to/repo
Is there a way to do this without modifying the HOME environment variable and without typing it out every time (which invites typo errors), or is specifying the location in the command line probably the best way?
EDIT: I'm using the GitHub for Windows GUI and Powershell.
You said that you're using the GitHub for Windows application, so you can configure it within the settings dialog. Hit Alt-T, press options and then you can change the default storage directory.
Git will by default clone into a new subdirectory of the current directory, so you could simply set up whatever shell/terminal you're using to start in the C:\Users\\Documents\GitHub
directory by default. If it's the regular cmd.exe
prompt, you should be able to configure this in the properties window of the shortcut you're using to open it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With