Moving directories for portable git configuration

I installed the portable version of git on my flash drive, but I do not want my repository to be in the same directory as the program. I can go to the directory using:

$ git -- git-dir=../Gits --work-tree=..Gits

But I do not want to enter it every time. Therefore, I found this article in a file gitconfig. But it only shows how to installcore.worktree

core.worktree

Set the path to the root of the work tree. This can be overridden by the GIT_WORK_TREE environment variable and the command line -work-tree option. This can be an absolute path or a relative path to the .git directory, or it can be specified - git-dir or GIT_DIR or automatically detected. If specified - git-dir or GIT_DIR but not a single tree -work, GIT_WORK_TREE and core.worktree are specified, the current working directory as the root of the work tree.

Note that this variable is executed even when configured in the configuration file in the ".git" subdirectory of the directory, and its value is different from the last directory (for example, "/path/to/.git/config" has core.worktree for "/ different / path "), which is most likely the wrong configuration. Running git commands in the "/ path / to" directory will still use "/ different / path" as the root of the working tree and can cause a lot of confusion for users.

I tried these settings to no avail.

[core]
  worktree = ../Gits
  gitdir = ../Gits

Does anyone know of a way to set the directories git-dirand work-treefor PortableGit-1.7.0.2-preview20100309.7z for Windows, so I do not have to enter it for all time?

, ? , , -, ~/.profile ~/.bashrc.

+3
1

- git , ?

%PATH% Git/cmd, "git whatever" git , git .

git ~/.profile ~/.bashrc: Git bashrc cd, pwd: - '~'.
, .profile .bashrc, , (echo .profile .profile, echo .bashrc ' .bashrc), git bashrc , .profile/.bashrc.

+5

Source: https://habr.com/ru/post/1752917/


All Articles