Let's say there's repository online, that I fork (or clone, not sure if it makes any difference), and then locally I make my own changes to different files, add other files, remove some files, etc.
I don't want those changes to be pushed to the original repo. I want that if the original repo changes, I can update my fork/clone with those changes, and then apply my own changes again onto the updated vesion.
Everything I find online kind of talks about this, but always with the final goal of pushing the local changes to the original repository, so that doesn't work for me.
What would be the strategy to accomplish what I explained above?
Fork is the right approach: it clones the repo on the server side, allowing you to have your own copy (to which you can push to).
This works for GitHub or BitBucket (which has also a fork)
Once clone, updating your fork with updates from the original repo has to go through your local clone first.
Meaning the update is done on your local repo and push to your fork (it cannot be done directly on your fork).
That local clone can declare 2 remotes:
upstream
', referring to the original repoorigin
', referring to your online fork.The key is to fetch upstream
, and rebase your local branch on top of upstream/master
.
See "Pull new updates from original Github repository into forked Github repository" for more.