移动目录以进行便携式 git 配置

发布于 2024-09-07 16:12:44 字数 1328 浏览 6 评论 0 原文

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

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

但我不想每次都输入该目录。所以我在这篇文章中找到了gitconfig文件。但它只展示了如何设置core.worktree

核心.worktree

设置工作树根的路径。这可以被覆盖 GIT_WORK_TREE 环境变量 和 --work-tree 命令行 选项。它可以是绝对路径或 .git 目录的相对路径, 由 --git-dir 指定或 GIT_DIR,或者自动发现的。 如果指定了 --git-dir 或 GIT_DIR 但没有 --work-tree, GIT_WORK_TREE 并且指定了 core.worktree , 当前工作目录被视为 作为工作树的根。

请注意,即使在配置文件中设置,也会遵守此变量 在“.git”子目录中 目录,其值不同于 后一个目录(例如 “/path/to/.git/config”有 core.worktree 设置为 “/不同/路径”),这是最 可能是配置错误。运行git “/path/to”目录中的命令将 仍然使用“/ different/path”作为 工作树的根并可能导致 给用户带来很大的困惑。

我尝试过这些设置没有效果。

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

有谁知道如何设置 PortableGit-1.7.0.2-preview20100309.7z 适用于 Windows,这样我就不必一直输入它?

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

I have installed the portable git version on my flash drive, but I don't want my repository to be in the same directory as the program. I can get to the directory using:

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

But I don't want to enter that every time. So I found in this article on the gitconfig file. But it only shows how to set the 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.

I have tried these settings to no avail.

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

Does anyone know a way to set the git-dir and work-tree directories for PortableGit-1.7.0.2-preview20100309.7z for Windows so I don't have to type that in all the time?

Also is there a way to add the passphrase so I don't have to type that in either? I saw these instructions, but the portable version apparently doesn't have a ~/.profile or ~/.bashrc file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小嗲 2024-09-14 16:12:44

为什么 git repo 会与您的便携式安装位于同一目录中?

只要您的 %PATH% 引用您的便携式 Git/cmd 目录,您就可以在 Git 存储库中的任何位置键入“gitwhat”,工作目录和 git 目录将位于默认位置。

任何 Git 版本都可以访问 ~/.profile~/.bashrc:打开 Git bashrc,然后输入 cd< /code>,然后 pwd:显示的路径是您的“~”。
然后,如果您还没有 .profile.bashrc,请创建一个,并将其放入一个简单的 echo (echo .profile 中的 < code>.profile
文件,在 .bashrc 中'echo .bashrc'),打开另一个 Git bashrc 并检查您的 .profile/.bashrc 已激活。

Why would any git repo in the same directory than your portable installation?

As long as your %PATH% reference your portable Git/cmd directory, you can just type 'git whatever' in your Git repo anywhere, and the working directory and git directory will be at their default places.

And any Git version has access to ~/.profile or ~/.bashrc: open a Git bashrc, and type cd, then pwd: the path displayed is your '~'.
Then, if you have no .profile or .bashrc yet, create one, put it it a simple echo (echo .profile in the .profile file, 'echo .bashrc' in the .bashrc), open another Git bashrc and check if your .profile/.bashrc are activated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文