0. Introduction
After installing git under Windows, Git's default home and ~ paths are typically C:\Users\ usernames, and each time you have to switch to a common repository with a command, the operation is repetitive and meaningless. In order to modify the default path, there are two methods: (1) Modify the git/etc/profile correlation parameter; (2) press Windows to create the environment variable, Home, and then set the path.
1. Modify profile-related parameters
(1) for Git version 1.x
The author takes git version 1.9.5.msysgit.1 as an example.
Open Git/etc/profile and find
# normalize HOME to UNIX path Home= ""$HOME" ; PWD)"export PATH="$HOME/bin: $PATH"
Add two lines and the modified code is as follows
# normalize HOME to UNIX path Home=" you want to modify the home path "Home=""$HOME" ; PWD)"cdexport PATH="$HOME/bin: $PATH"
When you start Git bash again, it will automatically go to the newly modified HOME path, then the newly configured. The SSH folder is also in the new path.
(2) HACK
If you are a Windows system, you can add a variable name for your convenience to customize your project directory, which is not only convenient for path jumps, but it also allows you to automatically enter the project directory when you start Git. The method is extremely simple, simply include in the profile file:
# Set Project Pathproj=" your project files directory "CD $proj
As the code says, you can use the CD $proj command to jump to the project directory or define other variables as needed.
If you know a lot about Bush, you should be able to guess how Linux's bash configuration scheme should work. And it is true that there is a BASHRC.
Create a new file in the home directory. BASHRC writes your most favorite configuration, such as Alias, Bind, export, and so on, and executes the source ~/.BASHRC with immediate effect.
"References"
Portable Git for windows:setting the $HOME environment variable to allow complete portability (including SSL keys and con Figuration for use with GitHub)
2. Create environment variables by Windows
The author uses git version 2.6.3.windows.1, whose profile file changes a large, in another way to modify the HOME default path.
Take Windows 7 as an example:
Advanced system settings (System Properties), properties, computers, environment variables-User variables add a Home variable, specifying its value as [Drive letter]:\[your directory] (for example: D:\file). Click OK to exit. Then turn on Git Bash again.
HOME default path for configuring GIT bash in Windows environment