I found a lot of q & a about synchronizing a forked git repository with the original remote repository but none applied to my exact problem.
Let's assume I forked a project with a remote name of upstream, my fork's name is origin. I have a master and a dev branch locally that track master and dev of origin.
As long as I make no changes to my forked repo I know I can sync my forked repo at origin with upstream/master by
git checkout master
git pull upstream master
git push origin master
So far, so good. But now I work on my local dev branch and once I'm done I would like to merge it into my local master. But first I would bring my local master up to date with the changes in upstream by
git checkout master
git pull upstream master
git push origin master
First Question(s): Is this correct? But then what would I do with my local dev branch? Rebase it on my updated master before merging it into my local master or try to merge it without rebasing? Or should I try to keep my local dev in sync with upstream/master all along, by pulling in upstream/master from time to time?
Once this is accomplished I would
git push origin master
and delete my dev branch, locally and in origin. But now my master (locally and in origin) deviates from upstream/master by the changes made by my local dev.
Second Question: What is the proper way to go now to keep in sync with upstream/master? Do I still simply do
git checkout master
git pull upstream master
git push origin master
or is anything else recommended here (e.g. some form of rebasing)? If I created a branch dev again, would I apply the same strategy that applied for the first question again or would something else apply?
Thanks for your help!