How to create alias for Git Bash on Windows 10? I need to create an alias of the long path to my project folder so I don't have to type it again and again whenever I open bash. I've searched for answers and tried several "correct answers" but none has worked for me so far.
They include:
create a .bashrc
or some people suggest .bashrc.
(after creating this file, I cannot do anything with it. windows says
Could not find this item This is no longer located in C:\. Verify the item's location and try again.
)
echo alias='<path>' > .bashrc
(iI've also tried >>)
I can edit the file .bashrc
and put aliases in there but none of them works.
I've tried editing the .gitconfig
file in my home folder [alias] =''
Same result whenever I type: cd <alias name>
:
No such file or directory
All I need to do is to type: cd and it will lead me to ~///...
Console Aliases in Windows 10. To define a console alias, use Doskey.exe to create a macro, or use the AddConsoleAlias function.
An bash shell alias is nothing but the shortcut to commands. The alias command allows the user to launch any command or group of commands (including options and filenames) by entering a single word. Use alias command to display a list of all defined aliases. You can add user-defined aliases to ~/.
These aliases were created with the --global flag which means they will be stored in Git's global operating system level configuration file. On linux systems, the global config file is located in the User home directory at /. gitconfig .
Try this:
i
to go edit mode and update it with you alias command.Esc
and press :wq
(save and exit)if this didn't work create the .bash_profile
in the same way and add the line
if [ -f ~/.bashrc ]; then . ~/.bashrc; fi
you can also open and edit the file aliases.sh that you find in the installation path of git
C:\path where you installed Git\etc\profile.d\aliases.sh
Open it with atom or notepad++ and add a line like
alias MyProjectName='C:/<installation_path_of_your project>/'
and save.
close and reopen git bash
now if you write
MyProjectName
on Bash, it should automatically bring you tothe desired path.
If it doesn't work try with
cd MyProjectName
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