git-filter-repo | Quickly rewrite git repository history | Search Engine library

 by   newren Python Version: 2.38.0 License: Non-SPDX

kandi X-RAY | git-filter-repo Summary

kandi X-RAY | git-filter-repo Summary

git-filter-repo is a Python library typically used in Database, Search Engine applications. git-filter-repo has no bugs, it has no vulnerabilities and it has high support. However git-filter-repo build file is not available and it has a Non-SPDX License. You can install using 'pip install git-filter-repo' or download it from GitHub, PyPI.

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

            kandi-support Support

              git-filter-repo has a highly active ecosystem.
              It has 5723 star(s) with 641 fork(s). There are 46 watchers for this library.
              OutlinedDot
              It had no major release in the last 12 months.
              There are 73 open issues and 239 have been closed. On average issues are closed in 28 days. There are 10 open pull requests and 0 closed requests.
              OutlinedDot
              It has a negative sentiment in the developer community.
              The latest version of git-filter-repo is 2.38.0

            kandi-Quality Quality

              git-filter-repo has 0 bugs and 0 code smells.

            kandi-Security Security

              git-filter-repo has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              git-filter-repo code analysis shows 0 unresolved vulnerabilities.
              There are 0 security hotspots that need review.

            kandi-License License

              git-filter-repo has a Non-SPDX License.
              Non-SPDX licenses can be open source with a non SPDX compliant license, or non open source licenses, and you need to review them closely before use.

            kandi-Reuse Reuse

              git-filter-repo releases are available to install and integrate.
              Deployable package is available in PyPI.
              git-filter-repo has no build file. You will be need to create the build yourself to build the component from source.
              Installation instructions are not available. Examples and code snippets are available.

            Top functions reviewed by kandi - BETA

            kandi has reviewed git-filter-repo and discovered the below as its top functions. This is intended to give you an instant insight into git-filter-repo implemented functionality, and help decide if they suit your requirements.
            • 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 .
            Get all kandi verified functions for this library.

            git-filter-repo Key Features

            No Key Features are available at this moment for git-filter-repo.

            git-filter-repo Examples and Code Snippets

            Setup Git Filter Repo
            Shelldot img1Lines of Code : 10dot img1no licencesLicense : No License
            copy iconCopy
            #!/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  
            problem pushing changes to GitHub because of file that's not really there
            Pythondot img2Lines of Code : 3dot img2License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
             git rm -r '*.so' -f
             echo '*.so' >> .gitignore
            

            Community Discussions

            QUESTION

            git-filter-repo multiple operations (regex filter, move files, keep other dir...)
            Asked 2022-Jan-15 at 15:22

            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.

            Situation and expected result

            My git working directory looks like this:

            ...

            ANSWER

            Answered 2022-Jan-15 at 15:22

            Self 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:

            Source https://stackoverflow.com/questions/70720401

            QUESTION

            `git filter-repo` commands output nothing on Windows
            Asked 2021-Dec-01 at 06:58

            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:58

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

            1. Download and install Python for Windows. Confirm python was added to your path and that you can run either the command python or python3 from your Git command line. (I recommend Git Bash.) In my case, my executable name is python.
            2. Clone the git-filter-repo repo from GitHub.
            3. Run the command git --exec-path to see your Git exe directory.
            4. From the git-filter-repo repo's root directory, copy the file git-filter-repo (about 160KB) into your Git exe directory.
            5. 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."
            6. 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.

            Source https://stackoverflow.com/questions/69355161

            QUESTION

            Updating git repo after using git-filter-repo --subdirectory-filter
            Asked 2021-Oct-21 at 19:21

            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:21

            Since 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.

            Source https://stackoverflow.com/questions/69632636

            QUESTION

            How to change author of specific commits based on a predicate
            Asked 2021-Sep-05 at 01:23

            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:

            1. First find all commits that I'm trying to change.
            2. 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:11

            Thanks to @phd's help, I was able to figure out a working solution:

            Source https://stackoverflow.com/questions/69059210

            QUESTION

            Not able to push changes to github with large files
            Asked 2021-Jul-23 at 08:23

            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:52

            What 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)

            Source https://stackoverflow.com/questions/68495725

            QUESTION

            Use git-filter-repo to filter out a list of files in commits which are not descendants of a given commit
            Asked 2021-Jun-13 at 19:08

            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:08

            Use 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.

            Source https://stackoverflow.com/questions/67961146

            QUESTION

            Push to GitHub mistakenly done by another GitHub account
            Asked 2021-Mar-15 at 08:06

            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.

            What happened
            • The push succeeded and I saw the page of B reflected the commits of b.
            • However, the name of the user who had done the first push displayed on the page of B was not the name of b, but the name of the other GitHub account A-github.(The icon image was also the same as set in A-github page)
            • And when I clicked the name of the user who first pushed ( A-github), I went to the page of A-github account.
            • What is weird is that this happening is not recorded on Contribution activity on the Overview page of A-github.
            My guess

            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:58

            First, 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).

            Source https://stackoverflow.com/questions/66614236

            QUESTION

            How to modify remote history with git filter-repo?
            Asked 2021-Feb-25 at 23:56

            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:56

            Why does git-filter-repo remove my remote?

            The documentation explains their reasoning, in the section titled INTERNALS:

            1. 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.

            Source https://stackoverflow.com/questions/66373656

            QUESTION

            git init under python script called by git filter-branch uses wrong directory
            Asked 2021-Feb-12 at 21:29

            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:29

            What is wrong ...

            There are two things you must not do in a tree filter, in git filter-branch, in general:

            1. change the working directory;
            2. 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 evals 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.

            Source https://stackoverflow.com/questions/66167895

            QUESTION

            git filter-branch: Cannot rewrite branches: You have unstaged changes
            Asked 2021-Feb-12 at 07:50

            I run this command

            ...

            ANSWER

            Answered 2021-Feb-12 at 07:50

            Eventually 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.

            Source https://stackoverflow.com/questions/66147338

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install git-filter-repo

            You can install using 'pip install git-filter-repo' or download it from GitHub, PyPI.
            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

            See the contributing guidelines.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install git-filter-repo

          • CLONE
          • HTTPS

            https://github.com/newren/git-filter-repo.git

          • CLI

            gh repo clone newren/git-filter-repo

          • sshUrl

            git@github.com:newren/git-filter-repo.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link