Our git repo has a bunch of large files in its history that are no longer needed. I want to remove them using the filter-branch technique explained in Pro Git:
http://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery
I'll then use git push --force all
to send this to our shared repo, as explained here:
Update a development team with rewritten Git repo history, removing big files
BUT. Pro Git says I'll need to have everyone rebase since I'm changing history. We've only sparingly used rebase, usually just as an alternative way to merge. I can have everyone re-clone, but that's a last resort; several devs have local branches with changes they'd like to keep.
So: What exactly will everyone need to do in our local repositories to rebase onto the newly-changed shared repo? And do we have to do it once per tracking branch? Our repo is referred to as origin and the master branch is master, if you want to give step-by-steps (and I'd love it if you would).
The Golden Rule of Rebasing reads: “Never rebase while you're on a public branch.” This way, no one else will be pushing other changes, and no commits that aren't in your local repo will exist on the remote branch.
The history can be messed up using rebase, but normally remote repo will not accept the change that modifies the history (unless you use git push --force), but even more, the developer with push permission can delete the branch completely (git push origin :branch-name).
If you use pull requests as part of your code review process, you need to avoid using git rebase after creating the pull request. As soon as you make the pull request, other developers will be looking at your commits, which means that it's a public branch.
git-filter-branch can be used to get rid of a subset of files, usually with some combination of --index-filter and --subdirectory-filter .
The key is for each individual developer not to lose their original reference to master
until after they've done their rebase. To do this, have them do a fetch
(not a pull) after the forced push, then for each local branch, do:
git rebase --onto origin/master master <local_branch>
When that's done, then they can checkout their master
and update it by:
git pull --force
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With