Skip to main content
deleted 1 character in body
Source Link
zhangyu12
  • 191
  • 1
  • 3

git filter-branch is a powerful command which you can use it to delete a huge file from the commits history. The file will stay for a while and Git will remove it in the next garbage collection. Below is the full process from deleteing files from commit history. For safety, below process runs the commandcommands on a new branch first. If the result is what you needed, then reset it back to the branch you actually want to change.

# Do it in a new testing branch $ git checkout -b test # Remove file-name from every commit on the new branch # --index-filter, rewrite index without checking out # --cached, remove it from index but not include working tree # --ignore-unmatch, ignore if files to be removed are absent in a commit # HEAD, execute the specified command for each commit reached from HEAD by parent link   $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch file-name' HEAD # The output is OK, reset it to the prior branch master $ git checkout master $ git reset --soft test # Remove test branch $ git branch -d test # Push it with force $ git push --force origin master 

git filter-branch is a powerful command which you can use it to delete a huge file from the commits history. The file will stay for a while and Git will remove it in the next garbage collection. Below is the full process from deleteing files from commit history. For safety, below process runs the command on a new branch first. If the result is what you needed, then reset it back to the branch you actually want to change.

# Do it in a new testing branch $ git checkout -b test # Remove file-name from every commit on the new branch # --index-filter, rewrite index without checking out # --cached, remove it from index but not include working tree # --ignore-unmatch, ignore if files to be removed are absent in a commit # HEAD, execute the specified command for each commit reached from HEAD by parent link   $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch file-name' HEAD # The output is OK, reset it to the prior branch master $ git checkout master $ git reset --soft test # Remove test branch $ git branch -d test # Push it with force $ git push --force origin master 

git filter-branch is a powerful command which you can use it to delete a huge file from the commits history. The file will stay for a while and Git will remove it in the next garbage collection. Below is the full process from deleteing files from commit history. For safety, below process runs the commands on a new branch first. If the result is what you needed, then reset it back to the branch you actually want to change.

# Do it in a new testing branch $ git checkout -b test # Remove file-name from every commit on the new branch # --index-filter, rewrite index without checking out # --cached, remove it from index but not include working tree # --ignore-unmatch, ignore if files to be removed are absent in a commit # HEAD, execute the specified command for each commit reached from HEAD by parent link $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch file-name' HEAD # The output is OK, reset it to the prior branch master $ git checkout master $ git reset --soft test # Remove test branch $ git branch -d test # Push it with force $ git push --force origin master 
added 10 characters in body
Source Link
zhangyu12
  • 191
  • 1
  • 3

git filter-branch is a powerful command which you can use it to delete a huge file from the commits history. The file will stay for a while and Git will remove it in the next garbage collection. Below is the full process from deleteing files from commit history. For safety, you'd better first runbelow process runs the command on a new branch: first. If the result is what you needed, then reset it back to the branch you actually want to change.

# Do it in a new testing branch $ git checkout -b test # Remove file-name from every commit on the new branch # --index-filter, rewrite index without checking out # --cached, remove it from index but not include working tree # --ignore-unmatch, ignore if files to be removed are absent in a commit # HEAD, execute the specified command for each commit reached from HEAD by parent link $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch file-name' HEAD # The output is OK, reset it to the prior branch master $ git checkout master $ git reset --soft test # Remove test branch $ git branch -d test # Push it with force $ git push --force origin master 

git filter-branch is a powerful command which you can use it to delete a huge file from the commits history. The file will stay for a while and Git will remove it in the next garbage collection. Below is the full process from deleteing files from commit history. For safety, you'd better first run the command on a new branch:

# Do it in a new testing branch $ git checkout -b test # Remove file-name from every commit on the new branch # --index-filter, rewrite index without checking out # --cached, remove it from index but not include working tree # --ignore-unmatch, ignore if files to be removed are absent in a commit # HEAD, execute the specified command for each commit reached from HEAD by parent link $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch file-name' HEAD # The output is OK, reset it to the prior branch master $ git checkout master $ git reset --soft test # Remove test branch $ git branch -d test # Push it with force $ git push --force origin master 

git filter-branch is a powerful command which you can use it to delete a huge file from the commits history. The file will stay for a while and Git will remove it in the next garbage collection. Below is the full process from deleteing files from commit history. For safety, below process runs the command on a new branch first. If the result is what you needed, then reset it back to the branch you actually want to change.

# Do it in a new testing branch $ git checkout -b test # Remove file-name from every commit on the new branch # --index-filter, rewrite index without checking out # --cached, remove it from index but not include working tree # --ignore-unmatch, ignore if files to be removed are absent in a commit # HEAD, execute the specified command for each commit reached from HEAD by parent link $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch file-name' HEAD # The output is OK, reset it to the prior branch master $ git checkout master $ git reset --soft test # Remove test branch $ git branch -d test # Push it with force $ git push --force origin master 
added 10 characters in body
Source Link
zhangyu12
  • 191
  • 1
  • 3

git filter-branch is a powerful command which you can use it to delete a huge file from the commits history. The file will stay for a while and Git will remove it in the next garbage collection. Below is the full process from deleteing files from commit history. For safety, ityou'd better first run the command on a new branch:

# Do it in a new testing branch $ git checkout -b test # Remove file-name from every commit on the new branch # --index-filter, rewrite index without checking out # --cached, remove it from index but not include working tree # --ignore-unmatch, ignore if files to be removed are absent in a commit # HEAD, execute the specified command for each commit reached from HEAD by parent link $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch file-name' HEAD # The output is OK, reset it to the prior branch master $ git checkout master $ git reset --soft test # Remove test branch $ git branch -d test # Push it with force $ git push --force origin master 

git filter-branch is a powerful command which you can use it to delete a huge file from the commits history. The file will stay for a while and Git will remove it in the next garbage collection. Below is the full process from deleteing files from commit history. For safety, it first run the command on a new branch:

# Do it in a new testing branch $ git checkout -b test # Remove file-name from every commit on the new branch # --index-filter, rewrite index without checking out # --cached, remove it from index but not include working tree # --ignore-unmatch, ignore if files to be removed are absent in a commit # HEAD, execute the specified command for each commit reached from HEAD by parent link $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch file-name' HEAD # The output is OK, reset it to the prior branch master $ git checkout master $ git reset --soft test # Remove test branch $ git branch -d test # Push it with force $ git push --force origin master 

git filter-branch is a powerful command which you can use it to delete a huge file from the commits history. The file will stay for a while and Git will remove it in the next garbage collection. Below is the full process from deleteing files from commit history. For safety, you'd better first run the command on a new branch:

# Do it in a new testing branch $ git checkout -b test # Remove file-name from every commit on the new branch # --index-filter, rewrite index without checking out # --cached, remove it from index but not include working tree # --ignore-unmatch, ignore if files to be removed are absent in a commit # HEAD, execute the specified command for each commit reached from HEAD by parent link $ git filter-branch --index-filter 'git rm --cached --ignore-unmatch file-name' HEAD # The output is OK, reset it to the prior branch master $ git checkout master $ git reset --soft test # Remove test branch $ git branch -d test # Push it with force $ git push --force origin master 
-d not -rm for removing a branch
Source Link
Loading
Source Link
zhangyu12
  • 191
  • 1
  • 3
Loading