gpt4 book ai didi

windows - 为可移植 git 配置移动目录

转载 作者:可可西里 更新时间:2023-11-01 14:07:38 26 4
gpt4 key购买 nike

我已经在我的闪存驱动器上安装了可移植 git 版本,但我不希望我的存储库与程序位于同一目录中。我可以使用以下方法进入目录:

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

但我不想每次都输入那个。所以我在this article中找到了在 gitconfig 文件中。但它只显示了如何设置 core.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 --work-tree command line option. It can be an absolute path or a relative path to the .git directory, either specified by --git-dir or GIT_DIR, or automatically discovered. If --git-dir or GIT_DIR are specified but none of --work-tree, GIT_WORK_TREE and core.worktree is specified, the current working directory is regarded as the root of the work tree.

Note that this variable is honored even when set in a configuration file in a ".git" subdirectory of a directory, and its value differs from the latter directory (e.g. "/path/to/.git/config" has core.worktree set to "/different/path"), which is most likely a misconfiguration. Running git commands in "/path/to" directory will still use "/different/path" as the root of the work tree and can cause great confusion to the users.

我试过这些设置都无济于事。

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

有谁知道为 PortableGit-1.7.0.2-preview20100309.7z 设置 git-dirwork-tree 目录的方法吗?适用于 Windows,所以我不必一直输入它?

还有没有一种方法可以添加密码,这样我就不必再输入密码了?我看到了these instructions ,但便携版显然没有 ~/.profile~/.bashrc 文件。

最佳答案

为什么任何 git repo 都在与可移植安装相同的目录中?

只要你的 %PATH% 引用了你的可移植 Git/cmd 目录,你就可以在你的 Git 中输入 'git whatever' repo 任何地方,工作目录和 git 目录将在它们的默认位置。

并且任何 Git 版本都可以访问 ~/.profile~/.bashrc:打开一个 Git bashrc,然后输入 cd,然后是pwd:显示的路径就是你的'~'。
然后,如果你还没有 .profile.bashrc,创建一个,把它放在一个简单的 echo (echo .profile in the .profile 文件, 'echo .bashrc' in the .bashrc), 打开另一个 Git bashrc 并检查你的 .profile/.bashrc 被激活。

关于windows - 为可移植 git 配置移动目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3169355/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com