你如何安装 git-filter-repo?

CBF*_*BFT 16 python git source-control installation

我正在尝试使用 git-filter-repo 从我的存储库中删除大型二进制文件。我以前没有使用过python。我通过单击下载的 .exe 文件安装了最新的 python,因为这是 git-filter-repo 的要求。指令说:

git-filter-repo 是一个单文件 python 脚本,它是为了使基本使用的安装变得简单:只需将它复制到您的 $PATH 中

https://github.com/newren/git-filter-repo/#how-do-i-install-it

我试过用 python 应用程序打开 git-filter-repo.py。我也不能在 python 应用程序中使用 cd、ls 或 dir。

小智 18

在 Mac 上,您可以使用自制程序安装它:

$ brew install git-filter-repo


Cir*_*郝海东 16

pip install

他们现在有一个可以正常工作的python包:

python3 -m pip install --user git-filter-repo
Run Code Online (Sandbox Code Playgroud)

该方法会安装命令行可执行文件和 Python 库,您可以使用该库,如下所示

可执行文件名为git-filter-repo,Git 会在调用之类的调用中自动选取任何PATH带有名称的可执行文件,这就是它的工作原理。git-*git *

或者,如果由于某种原因您不想使用 pip,您也可以:

# Add to bashrc.
export PATH="${HOME}/bin:${PATH}"

mkdir -p ~/bin
wget -O ~/bin/git-filter-repo https://raw.githubusercontent.com/newren/git-filter-repo/7b3e714b94a6e5b9f478cb981c7f560ef3f36506/git-filter-repo
chmod +x ~/bin/git-filter-repo
Run Code Online (Sandbox Code Playgroud)

在 Ubuntu 20.04 上测试,git-filter-repo ac039ecc095d。

  • 我在 Windows 中使用 pip 安装了该软件包,但仍然得到“git: 'filter-repo' is not a git command”。 (2认同)

CBF*_*BFT 7

这就是我让它工作的方式。

  1. 应安装 Python 并将其添加到系统路径中。
  2. 应该安装 Git 并将 git 也添加到系统的路径中。
  3. 下载 git-filter-repo
  4. 将名为 git-filter-repo 的文件第一行中的 'python3' 替换为 'python'。根据您的 python 安装,您可以跳过此步骤。
  5. 调用 git --exec-path
  6. 将 git-filter-repo 文件移动到所示位置。(git 的路径)。
  7. 要使用,请键入 git filter-repo。帮助选项不起作用,但他们有在线文档。