13

I installed git-filter-repo via scoop, tried multiple git filter-repo commands e.g. git filter-repo -h, they all logged nothing, no warning or error, just nothing.

Tried rebooting, reinstalling, and installing it on another Windows 10 computer, all reproduced it.

git-filter-repo: v2.33.0
git: v2.33.0.windows.2
python: v3.9.7
scoop:

Current Scoop version:
09200504 (HEAD -> master, origin/master, origin/HEAD) reset: skip when app instance is running (#4359)

'main' bucket:
b71f4a842 (HEAD -> master, origin/master, origin/HEAD) nunit-extension-vs-project-loader: Update to version 3.9.0

How to solve this issue?

Wenfang Du
  • 8,804
  • 9
  • 59
  • 90
  • 1
    Use the command `git --exec-path` to see where your Git exes are installed. Then look in that directory for the file called `git-filter-repo`. Mine is a python script with an approx size of 160 KB. If it's there, open that file and look at the first line. If it has "python3" listed, try changing it to "python" (without the 3). – TTT Sep 28 '21 at 03:32
  • @TTT `git-filter-repo` doesn't exist in that folder, finally got a clue, thanks, what would cause this? – Wenfang Du Sep 28 '21 at 03:38
  • I guess scoop didn't do what you expected. ;) It's been a while but I'm pretty sure I just downloaded git-filter-repo from GitHub, and dropped that file in the Git folder, made the one change to remove the 3, and it worked. (Assuming you have python installed already, which you do.) – TTT Sep 28 '21 at 03:40
  • @TTT Amazing! I did exactly "downloaded git-filter-repo from GitHub, and dropped that file in the Git folder, made the one change to remove the 3" and it works now! You can post an answer for this, but I'm curious why `scoop` didn't generate `git-filter-repo` in the `git-core` folder and why changing `python3` to `python` makes the script work? – Wenfang Du Sep 28 '21 at 05:39
  • in git_filter_repo.py file, changing the first line from python3 to python saved the day. – hahuaz Jul 08 '23 at 13:48

2 Answers2

55

(Now updated for newer Python installers.)

When I installed git-filter-repo on Windows earlier this year, the following steps worked for me:

  1. Download and install Python for Windows. In newer installers you need to go into the Advanced Options to make sure Python is added to your Path: enter image description here

  2. Confirm python was added to your path and that you can run either the command python --version or python3 --version from your Git command line. (I recommend Git Bash.) In my case, my executable name is python and if yours is too, you will need this in step #7 below.

  3. Clone git-filter-repo from GitHub.

    git clone https://github.com/newren/git-filter-repo.git
    
  4. Run the command git --exec-path to see your Git exe directory.

  5. From the git-filter-repo repo's root directory, copy the file git-filter-repo (about 160KB) into your Git exe directory.

  6. In your command line where you use Git, type the command git filter-repo. If it works, you should get the message "No arguments specified." and you can skip step #7. If it doesn't work, it's likely that your python exe is python instead of python3 as determined in step #2. Go to the next step.

  7. If you get no message or an error message similar to "/usr/bin/env: ‘python3’: No such file or directory", then edit the file git-filter-repo that you copied into your Git exe directory in step #5, and change the first line from "python3" to "python".

Now be amazed at how fast and awesome git-filter-repo is.

Still having problems? If you didn't add the environment variable in step #1, some people have had luck in step #7 by changing their python command to just "py". This is the python launcher which can auto-detect the highest version installed on your machine. More info here. I should point out that this did not work for me with python 3.10.7. I actually tried this first but ended up re-installing and enabling the option to "Add python to environment variables" as described above in step #1.

TTT
  • 22,611
  • 8
  • 63
  • 69
  • The issue is that at step 6, no message is logged, that's the hardest situation for debugging. – Wenfang Du Sep 28 '21 at 06:10
  • @WenfangDu But that's only when you used scoop right? If you did step 4 manually, I don't think you will get no output in step 6. – TTT Sep 28 '21 at 06:18
  • I think the root cause is `python3` itself logs nothing, and `scoop` uses it in the `git-filter-repo.ps1`, which in turn caused running `git-filter-repo.ps1` logs nothing. – Wenfang Du Sep 28 '21 at 06:21
  • 1
    Wow this was a must-read. All the docs for it is entirely Mac centric, so I really appreciated these Windows steps :) – FoxDeploy Mar 13 '22 at 18:35
  • 2
    on windows: step number 6, but with another message '/usr/bin/env: ‘python3’: Permission denied' : Is also solved by rename python3 to python ; note : (if you run python3 in command line you will see it does'nt exist, for me, in powershell, Windows Store pops. But running "python --version" shows the same version as Store "promotes" – JimiSweden Apr 15 '22 at 13:10
  • 3
    And if you installed Python 3.10 or above, it would seem that it's "py" rather than "python3" or "python" that you need to put in the file. – FTWinston May 31 '22 at 14:04
  • 1
    @FTWinston I'm not sure if that is specific to 3.10 or not, because `py` is the Python Launcher that comes with earlier versions as well, and is supposed to be able to discover the highest version installed. It's a great tip though, and I incorporated it into the answer. Thanks. – TTT Jul 27 '22 at 14:45
10

In my case I followed this answer for Windows 11 and here is my experience.

  1. I installed Python from the windows store or from this link https://www.python.org/downloads enter image description here

  2. I run pip3 install git-filter-repo or python3 -m pip install --user git-filter-repo only for current user.

I got this message:

Requirement already satisfied: git-filter-repo in c:\users\username\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\site-packages

  1. Now copy that folder but replace site-packages with scripts.

Path: c:\users\username\appdata\local\packages\pythonsoftwarefoundation.python.3.10_qbz5n2kfra8p0\localcache\local-packages\python310\scripts

You will find git-filter-repo.exe inside the scripts folder.

  1. Run git --exec-path

You will get

C:/Program Files/Git/mingw64/libexec/git-core
  1. Copy git-filter-repo.exe to a folder in step 4 (C:/Program Files/Git/mingw64/libexec/git-core).

Now you should be able to run git filter-repo

Maytham Fahmi
  • 31,138
  • 14
  • 118
  • 137
  • 1
    worked like a charm – Ocean Airdrop Oct 06 '22 at 15:41
  • 2
    Worked for me on Windows 10 today - only 1 minor difference, instead of c:\users\username\appdata\local\packages\...\python310\site-package, it had installed here: C:\Users\username\AppData\Local\Programs\Python\Python311\Lib\site-packages. I had to replace the "Lib\site-packages" with "Scripts". Not sure if that is due to Windows 10 or Python 311 vs 310 or a choice I made during the installation. Regardless, this post got me there! – Mark W Nov 03 '22 at 19:26