git-filter-repo | Quickly rewrite git repository history | Search Engine library
kandi X-RAY | git-filter-repo Summary
kandi X-RAY | git-filter-repo Summary
git filter-repo is a versatile tool for rewriting history, which includes capabilities I have not found anywhere else. It roughly falls into the same space of tool as git filter-branch but without the capitulation-inducing poor performance, with far more capabilities, and with a design that scales usability-wise beyond trivial rewriting cases. git filter-repo is now recommended by the git project instead of git filter-branch. While most users will probably just use filter-repo as a simple command line tool (and likely only use a few of its flags), at its core filter-repo contains a library for creating history rewriting tools. As such, users with specialized needs can leverage it to quickly create entirely new history rewriting tools.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create argument parser .
- Write stats to a reportdir .
- Apply filters to files .
- Parse a commit line .
- Parse mailmap file .
- Check if the path is an ancestor of the check .
- Convert a glob to a regular expression .
- Get the sizes of blobs by sha1 .
- Wrap a single commit .
- Records a relationship between two commits .
git-filter-repo Key Features
git-filter-repo Examples and Code Snippets
#!/bin/zsh
git clone git@github.com:newren/git-filter-repo.git /tmp/git-filter-repo
cd /tmp/git-filter-repo
make snag_docs
cp -a git-filter-repo $(git --exec-path)
cp -a Documentation/man1/git-filter-repo.1 $(git --man-path)/man1
cp -a Documentation
git rm -r '*.so' -f
echo '*.so' >> .gitignore
Community Discussions
Trending Discussions on git-filter-repo
QUESTION
I'm trying to filter a repository with git-filter-repo
. I was trying to do this by describing all my needed operations in a path file to be used in a --paths-from-file
stanza as described in the documentation but I'm stuck in a last step to finalize this in one single and easy step.
My git working directory looks like this:
...ANSWER
Answered 2022-Jan-15 at 15:22Self answering as laying out the problem helped me spot the issue. I missed one important note in the documentation about path renaming.
Note: if you combine path filtering with path renaming, be aware that a rename directive does not select paths, it only says how to rename paths that are selected with the filters.
So one must describe all paths to be selected in the original repo prior to renaming them. Hence in my case the regex must be defined twice: once as a simple path filter and the other as a rename. The following path file is perfectly doing the job in a single run:
QUESTION
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
:
ANSWER
Answered 2021-Dec-01 at 06:58When I installed git-filter-repo
on Windows earlier this year, the following steps worked for me:
- Download and install Python for Windows. Confirm python was added to your path and that you can run either the command
python
orpython3
from your Git command line. (I recommend Git Bash.) In my case, my executable name ispython
. - Clone the
git-filter-repo
repo from GitHub. - Run the command
git --exec-path
to see your Git exe directory. - From the
git-filter-repo
repo's root directory, copy the filegit-filter-repo
(about 160KB) into your Git exe directory. - 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." - 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 #4, and change the first line from "python3" to "python".
Now be amazed at how fast and awesome git-filter-repo
is.
QUESTION
I have extracted a tools folder to it's own repo using:
git-filter-repo --subdirectory-filter path/to/tools
In parallel, new commits are being made in the original repo.
I would like to be able to periodically merge the changes into my filtered repo. The only thing I can think is to clone the original repo again (with the changes), apply the subdirectory-filter on it again, add it as a remote to my repo, then cherry-pick/merge the branch from there. It is a lot to perform every time there is a small change. I think there's probably a smart way to create a filtered patch from the main repo and then apply it to the filtered, but my git-skills are not sufficient.
Can someone come up with a better way to do it?
...ANSWER
Answered 2021-Oct-21 at 19:21Since git filter-repo
will recreate the exact same commits if you run it twice on the exact same history (you confirmed it by testing), you can simply use git merge
to integrate the new commits, which will appear as descendants of the previous extracted commit.
QUESTION
All answers I see regarding this question (here, here) only ever offer ways to either change the most recent commit(s) or all commits, however I want to change the author of only past commits that match a certain predicate. I have looked at git filter-branch (deprecated), git-filter-repo (its replacement), and bfg, but can't figure out how to make this change.
The way I intuitively tried to approach this is:
- First find all commits that I'm trying to change.
- Change author of those commits.
I have other commits in the history with the same author that I do not want to change, I only want to change commits that match a certain predicate.
So for step 1, find all commits whose commit messages have a specific substring:
...ANSWER
Answered 2021-Sep-04 at 23:11Thanks to @phd's help, I was able to figure out a working solution:
QUESTION
Hi i am facing issue with Git not able to push commit to remote.
I have the changes locally.
...ANSWER
Answered 2021-Jul-23 at 07:52What is probably the "real" answer is git-lfs like the error message suggests, which github does have support for, but it costs money when over 2GB. If your not in a position that that is available I found this post about how to work around the 100mb file size limit which some have to do with compression which would work well with .fbx files (becuase they are plain text and that compresses well)
Extra note that you left some information in the question that you might potentially want to remove (like your email)
QUESTION
It seems git filter-branch
is deprecated and git-filter-repo
should be used instead. I am using git filter-branch --index-filter
to remove a list of files from commits which are not descendants of a given commit. This is done like
ANSWER
Answered 2021-Jun-13 at 19:08Use git filter-branch
for what it's good for, use git filter-repo
for what it's better for. I doubt it's possible to make filter-repo do what you're after at all, or at any rate not nearly so well.
I recommend simply ignoring most of the criticisms leveled at git filter-branch, particularly the ones in the filter-repo readme, as regrettably overstated. Put export FILTER_BRANCH_SQUELCH_WARNING=1
in ~/.bashrc
and be done with it.
QUESTION
I had a local repository named a
which had been already associated with a remote repository named A
of GitHub account A-github
,
and I also had a local repository named b
which had not been associated with any remote repository yet.
I created a new remote repository named B
of GitHub account B-github
, and I tried to do the first push to B
from local repository b
.
- The push succeeded and I saw the page of
B
reflected the commits ofb
. - However, the name of the user who had done the first push displayed on the page of
B
was not the name ofb
, but the name of the other GitHub accountA-github
.(The icon image was also the same as set inA-github
page) - And when I clicked the name of the user who first pushed (
A-github
), I went to the page ofA-github
account. - What is weird is that this happening is not recorded on
Contribution activity
on the Overview page ofA-github
.
I'm guessing this was the problem of git config
of the local repository b
. I tried git config -l
and found that user.name
and user.email
were doubled like this:
ANSWER
Answered 2021-Mar-13 at 13:58First, do a git config -l --show-scope --show-origin
in your repository: that way, you will be sure to see what is a local config, which overrides a global config.
Second, you can use git filter-repo
to change the user.name/email of your commits in repoB: yo will then need to git push --force
it (which is not a big issue if you are alone working on that new repository).
QUESTION
In the past I've used git filter-branch
to remove files from my git history. Following that, I can do a force push to update the remote repository. For example, removing all HTML files from the local repo and then rewriting the remote to reflect the change:
ANSWER
Answered 2021-Feb-25 at 23:56Why does git-filter-repo remove my remote?
The documentation explains their reasoning, in the section titled INTERNALS:
- We don’t want users accidentally pushing back to the original repo, as discussed in DISCUSSION. It also reminds users that since history has been rewritten, this repo is no longer compatible with the original. Finally, another minor benefit is this allows users to push with the
--mirror
option to their new home without accidentally sending remote tracking branches.
And how can I rewrite remote's history using git-filter-repo like I'm able to with git filter-branch?
Just use git remote add
to put origin
back, or—since step 3 in the command sequence is git remote rm origin
—just rename origin
to some other name first. If you do that, though, note step 2.
You said:
Adding back the remote manually puts me down a rabbit hole of other settings be invalid.
You'll need to go into more detail here, obviously.
QUESTION
I run the following MWE of python script to read throw commits and create another git projec somewhere else.
I call this script this way to iterate through git projectA and create another git projectB under bash command of
...ANSWER
Answered 2021-Feb-12 at 21:29What is wrong ...
There are two things you must not do in a tree filter, in git filter-branch
, in general:
- change the working directory;
- use Git commands.
This is not necessarily an exclusive list, and, luckily, there are some ways around these two.
and how to fix this problem?
The limitation on changing directories is actually specific to shell commands run in the top level shell (filter-branch eval
s your filter here). Since you're firing up a completely separate process, python
, that allows you to change the working directory. But it's worth mentioning the issue, since an attempt to optimize your filter might result in running into it.
The limitation on using Git commands is because a tree filter is specifically aimed at letting you use non-Git commands to rework the contents of each commit. Using git filter-branch
simply to examine the contents of each commit wasn't the intent here.
Fortunately, there is a simple workaround for running git init
like this: you just need to remove the environment variable GIT_DIR
from the environment when you invoke Git. If you invoke other Git commands there may be more environment variables you must unset.
Overall, though, it's not clear why you're trying to use git filter-branch
for this. If you want to get a list of commits, the correct tool is usually git rev-list
. If you want to get files from those commits, things get more complex, but filter-branch is still probably not the right tool.
QUESTION
I run this command
...ANSWER
Answered 2021-Feb-12 at 07:50Eventually find the problem root cause.
It seems that running git filter-branch
in a network directory is not that robust. I copied the files to the local machine and could successfully run git filter-branch
command.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install git-filter-repo
You can use git-filter-repo like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page