Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create alias for git bash to make fast cd through directories

I'm using git bash and let say i have 2 folders: C:/folder1 and C:/folder2, I'd like to make fast cd from one to another.

I've tried git.alias but it seems to work for "git ..." commands only.. and I'm not very familiar with all this bash stuff.. so how should I do that?

like image 760
silver_rocket Avatar asked Dec 18 '14 08:12

silver_rocket


People also ask

How do I go to a specific directory in git bash?

just right click on the desired folder and select git-bash Here option it will direct you to that folder and start working hope it will work. Show activity on this post. if you are on windows then you can do a right click from the folder where you want to use git bash and select "GIT BASH HERE".

What is a repository alias?

A Git alias can be either local or global. A local alias is defined for a particular git repository whereas a global alias can be used in any repository. If you create an alias inside a git repository without the global flag, then the alias will be local by default i.e. it can be used in the current repository only.


1 Answers

In bash you could do the following to create alias:

alias cdf1="cd /user/home/cloudera"
cd /user
cdf1
pwd

You will get result of pwd as /user/home/cloudera. You could do the same in git-bash prompt as well with directory as "C:/folder1" instead of "/user/home/cloudera".

like image 178
SMA Avatar answered Oct 06 '22 19:10

SMA