简体   繁体   中英

how to pull updates from remote repo, when filter-branch is used on local repo?

for example i want to hack on the code of angularjs, so i simply clone it using git clone https://github.com/angular/angular.git , to simulate the update scenario, i would use git reset --hard HEAD~10 to discard recent commits, git pull works greatly after reset, because it can get updates from remote repo easily, but with filter-branch, git pull is painful, my question is how to deal with such painfulness.

since i can only hack on my own repo, sometime some of the original repo may have some directory that i don't want, for example some project may have node_modules in the repo, here i take the script folder as an example, i should remove using filter-branch on my local repo, but after git filter-branch --tree-filter "rm scripts -rf" , it's erroneous to get update from the original repo,

git pull after filter-branch, it's erroneous, and difficult to manage the conflicts.

so how to deal with repos that is not well managed that i have to use filter-branch remove operation, the problem is how to get update after filter-branche operation, is there a nice solution to this staff?

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 reach for regularly.

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

git rm -r scripts

and then commit. This will create a new commit removing the scripts directory while keeping previous commits as they already exist.

Operations that "change" commits, including filter-branch , should be strongly avoided on shared commits. These kinds of operations cause all kinds of complications, some of which you are discovering now.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM