<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=Git_remove_file_from_history</id>
	<title>Git remove file from history - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://tech.uvoo.io/index.php?action=history&amp;feed=atom&amp;title=Git_remove_file_from_history"/>
	<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=Git_remove_file_from_history&amp;action=history"/>
	<updated>2026-04-19T22:04:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.2</generator>
	<entry>
		<id>https://tech.uvoo.io/index.php?title=Git_remove_file_from_history&amp;diff=5371&amp;oldid=prev</id>
		<title>Busk at 16:54, 9 October 2024</title>
		<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=Git_remove_file_from_history&amp;diff=5371&amp;oldid=prev"/>
		<updated>2024-10-09T16:54:56Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:54, 9 October 2024&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l3&quot; &gt;Line 3:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 3:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To remove a binary file from the entire Git history to reduce the size of the repository, you can use the `git filter-repo` tool. This tool is more efficient and easier to use than the older `git filter-branch`.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;To remove a binary file from the entire Git history to reduce the size of the repository, you can use the `git filter-repo` tool. This tool is more efficient and easier to use than the older `git filter-branch`.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;### &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;Step-by-Step Guide&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;### &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;Steps&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;1. **Install `git filter-repo`**:&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;1. **Install `git filter-repo`**:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Busk</name></author>
	</entry>
	<entry>
		<id>https://tech.uvoo.io/index.php?title=Git_remove_file_from_history&amp;diff=5370&amp;oldid=prev</id>
		<title>Busk: Created page with &quot;# Remove binary file from git history in order to reduce size of git clone  To remove a binary file from the entire Git history to reduce the size of the repository, you can u...&quot;</title>
		<link rel="alternate" type="text/html" href="https://tech.uvoo.io/index.php?title=Git_remove_file_from_history&amp;diff=5370&amp;oldid=prev"/>
		<updated>2024-10-09T16:54:38Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;# Remove binary file from git history in order to reduce size of git clone  To remove a binary file from the entire Git history to reduce the size of the repository, you can u...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;# Remove binary file from git history in order to reduce size of git clone&lt;br /&gt;
&lt;br /&gt;
To remove a binary file from the entire Git history to reduce the size of the repository, you can use the `git filter-repo` tool. This tool is more efficient and easier to use than the older `git filter-branch`.&lt;br /&gt;
&lt;br /&gt;
### Step-by-Step Guide&lt;br /&gt;
&lt;br /&gt;
1. **Install `git filter-repo`**:&lt;br /&gt;
   - If you don't have `git filter-repo` installed, you can install it using `pip`:&lt;br /&gt;
&lt;br /&gt;
   ```bash&lt;br /&gt;
   pip install git-filter-repo&lt;br /&gt;
   ```&lt;br /&gt;
&lt;br /&gt;
2. **Clone the Repository**:&lt;br /&gt;
   - Clone your repository to a local directory:&lt;br /&gt;
&lt;br /&gt;
   ```bash&lt;br /&gt;
   git clone --mirror https://github.com/your-username/your-repo.git&lt;br /&gt;
   cd your-repo.git&lt;br /&gt;
   ```&lt;br /&gt;
&lt;br /&gt;
3. **Remove the Binary File**:&lt;br /&gt;
   - Use `git filter-repo` to remove the binary file from the entire history. Replace `path/to/binary-file` with the actual path to the binary file you want to remove:&lt;br /&gt;
&lt;br /&gt;
   ```bash&lt;br /&gt;
   git filter-repo --path path/to/binary-file --invert-paths&lt;br /&gt;
   ```&lt;br /&gt;
&lt;br /&gt;
4. **Force Push the Changes**:&lt;br /&gt;
   - Force push the rewritten history to the remote repository:&lt;br /&gt;
&lt;br /&gt;
   ```bash&lt;br /&gt;
   git push --force --mirror&lt;br /&gt;
   ```&lt;br /&gt;
&lt;br /&gt;
### Example&lt;br /&gt;
&lt;br /&gt;
Assuming you want to remove a binary file located at `binaries/large-file.bin`, here are the commands you would run:&lt;br /&gt;
&lt;br /&gt;
```bash&lt;br /&gt;
# Install git filter-repo if not already installed&lt;br /&gt;
pip install git-filter-repo&lt;br /&gt;
&lt;br /&gt;
# Clone the repository as a mirror&lt;br /&gt;
git clone --mirror https://github.com/your-username/your-repo.git&lt;br /&gt;
cd your-repo.git&lt;br /&gt;
&lt;br /&gt;
# Remove the binary file from the entire history&lt;br /&gt;
git filter-repo --path binaries/large-file.bin --invert-paths&lt;br /&gt;
&lt;br /&gt;
# Force push the changes to the remote repository&lt;br /&gt;
git push --force --mirror&lt;br /&gt;
```&lt;br /&gt;
&lt;br /&gt;
### Important Considerations&lt;br /&gt;
&lt;br /&gt;
- **Backup**: Before performing these operations, make sure to backup your repository. These changes are destructive and cannot be undone.&lt;br /&gt;
- **Collaboration**: Inform your collaborators about the history rewrite. They will need to re-clone the repository to avoid issues.&lt;br /&gt;
- **GitHub Actions and CI/CD**: If you use GitHub Actions or other CI/CD tools, ensure that the changes do not disrupt your workflows.&lt;br /&gt;
&lt;br /&gt;
### Alternative: BFG Repo-Cleaner&lt;br /&gt;
&lt;br /&gt;
Another tool you can use is the BFG Repo-Cleaner, which is designed to remove large files and sensitive data from Git repositories.&lt;br /&gt;
&lt;br /&gt;
1. **Download BFG Repo-Cleaner**:&lt;br /&gt;
   - Download the BFG jar file from the [official site](https://rtyley.github.io/bfg-repo-cleaner/).&lt;br /&gt;
&lt;br /&gt;
2. **Run BFG Repo-Cleaner**:&lt;br /&gt;
   - Use BFG to remove the binary file:&lt;br /&gt;
&lt;br /&gt;
   ```bash&lt;br /&gt;
   java -jar bfg.jar --delete-files binaries/large-file.bin&lt;br /&gt;
   ```&lt;br /&gt;
&lt;br /&gt;
3. **Clean Up and Push**:&lt;br /&gt;
   - Follow up with a `git gc` and force push:&lt;br /&gt;
&lt;br /&gt;
   ```bash&lt;br /&gt;
   git reflog expire --expire=now --all &amp;amp;&amp;amp; git gc --prune=now --aggressive&lt;br /&gt;
   git push --force&lt;br /&gt;
   ```&lt;br /&gt;
&lt;br /&gt;
By following these steps, you can remove a binary file from the entire Git history, reducing the size of your repository and making `git clone` operations faster.&lt;/div&gt;</summary>
		<author><name>Busk</name></author>
	</entry>
</feed>