![]() docker run -rm -it -v $:/app -w /app python:3 /bin/bash # inside the container, install git-filter-repo # Add the backports repo to sources.list echo 'deb bullseye-backports main' > /etc/apt//backports.list # Update the list of available packages apt-get update # Install git-filter-repo, adding the required /bullseye-backports suffix apt-get install -y git-filter-repo/bullseye-backports I ran the following command from inside my app to pull and run the Docker image, to map the current directory to the /app directory inside the container, set the working directory to /app, and to start a bash shell. ![]() The python:3 image is a bullseye (Debian 11) image, with Python 3.10 installed, which would do nicely. Git-filter-repo requires Python 3.5 , so I searched for Python on Docker Hub and found the official images. Instead of installing Python, I'll run a Docker image that already has Python installed, map the drive to my project, and work inside the docker image! Docker to the rescue!ĭocker is such a great use-case for something like this, where I want to quickly try a tool, and don't want to risk messing up my machine. Python on Windows can be problematic (even the install instructions make that clear) and while you can install Python from the Microsoft Store, I really didn't want to go through that. The only problem from my point of view, is that git-filter-repo is a Python module. I think you'll agree that's much clearer! The manual is also very good, with lots of examples. That whole git filter-branch expression in the previous section could be rewritten with git-filter-repo to be something like this: git filter-repo -path-rename engine/: And the really nice thing is that the API is so much nicer. In fact, it's a single Python file, but it's written to feel like a git plugin. Git-filter-repo isn't built-in to git itself. "Installing" git-filter-repo using Docker So instead of trying to figure out how to mangle git filter-branch to my liking, I decided to look at at a suggestion I saw elsewhere: git-filter-repo. Would you want to write your own? Almost certainly not. One of the suggested answers suggests running the following command: git filter-branch -f -index-filter 'PATHS=`git ls-files -s | sed "s/^engine//"` \GIT_INDEX_FILE=$GIT_INDEX_FILE.new \echo -n "$PATHS" | \git update-index -index-info \
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |