Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git "shortcut" for filepath?

Tags:

git

Is there some shortcut for filepath, because it's very annoying write full path again and again?

Some kind regular expression or something else.

I know, I can use "Tab" key, but...

UPDATE:

Windows and default sh.exe from Git

ANSWER:

Git extensions from holygeek are what I looking for, but his version is working only on *NIX like systems or cygwin with newer version of Bash.

That is reason, why I created little fix for msysgit => here

like image 916
MicTech Avatar asked Aug 12 '10 06:08

MicTech


People also ask

How do I open a path in git bash?

Using Windows Explorer, navigate to any directory you want, type "cmd" in the address bar it will open Windows command prompt in that directory. Along the same lines, if you have the git directory in your path, you can type "git-bash" in the address bar and a Git Shell will open in that directory.

How do I change the default directory in git?

Change Default Directory in Git Bash Right-click on Git Bash's shortcut icon and go to the Properties. In the Start in field, paste the path to the desired folder, e.g. D:\WorkDir.

How do I open properties in Git bash?

When I search git bash in the Start Menu and Open File Location of the shortcut, it brings me to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Git . Once we find our shortcut, we can right click the Git Bash shortcut and select Properties .


3 Answers

in the git-bash, try

declare -x YOURVARIABLENAMEHERE=C:/.../.../
cd $YOURVARIABLENAMEHERE

takes me right to the specified directory.

like image 89
mnodeland Avatar answered Oct 01 '22 19:10

mnodeland


I wrote a tool that allow me to use numbers when dealing with files in git (git-number).

I've been using it on linux (a couple of shell script and a perl script).

If you're feeling adventurous try to make it work on windows.

It's been a big productivity boost for me as I don't rely on tab completion nor do I need to write the long file or directory names anymore when manipulating files in git.

git-number: https://github.com/holygeek/git-number

like image 32
holygeek Avatar answered Oct 01 '22 19:10

holygeek


I understand what you're asking, but I'm not sure what kind of solution you're thinking of. If your filepath is potentially 'shortenable', why don't you change the names of the folders directly?

I'm no expert, but I suspect that for command-line usage, you won't find much better than what you've already got.

Using a GUI with a folder browser might be what you want? (for windows, for linux)

(If you're doing a lot of operations on multiple files in the same subfolder, you could navigate to that folder and run your commands from there - though you might want to check if the specific git commands you're using can handle that)

EDIT If there are just one or a couple of folders than you always need to refer to, you could set up a shell variable as bstpierre suggests in his comment on your question.

like image 21
Benjol Avatar answered Oct 01 '22 20:10

Benjol