How to fetch updates from a remote repo when the filter branch is in use in the local repo?

for example i want to hack angularjs code so i just clone it with git clone https://github.com/angular/angular.git

to simulate update script, i would use git reset --hard HEAD~10

to remove recent commits, git pull works significantly after reset because it can get updates from remote repo easily but with filter -branch, git pulls painfully, my question is how to deal with such painfulness.

since I can only hack my own repo, sometimes some of the original repo may have some directory that I don't need, for example, some project may have node_modules in the repo, here I take the script as an example, I have to delete using the filter branch on my local repo, but after git filter-branch --tree-filter "rm scripts -rf"

, mistakenly get the update from the original repo,

git pull out the filter-branch, this is buggy and difficult to deal with conflicts.

since working with repositories that are not well managed that i have to use the filter branches operation, the problem is how to get the update after filter-branche operation, is there a good solution for this staff?

+3


source to share


1 answer


When you use filter-branch

, you change the commit hashes of every commit in the branch. This should be a last resort, not something you visit regularly.

Instead, just remove the directory from your repository using something like

git rm -r scripts

      



and then commit. This will create a new commit, deleting the script directory, keeping the previous commits as they already exist.

Operations that commit "change", including filter-branch

, should be avoided on shared commits. These types of surgeries cause all sorts of complications, some of which you are discovering now.

+3


source







All Articles