I'm new to git, I've been following this tutorial.
I think I understand most of it, until I got to remote repositories. The only concept about remote repositories I understood is git fetch and git remote. According to that tutorial, git fetch gets the remote repository from the specified url by the add option of git remote. It downloads the repository into a "remote" branch. If I understood correctly, it isn't a branch in a remote repository but the branch I downloaded from the remote repository. It isn't part of my local repository just yet, it's still there to be merged/rebased into it (my local repository). Maybe I'm wrong and I'm missing something here, please feel free to correct me.
Now, what I feel I don't understand at all is how does git manage to rebase the "remote" repository into my local repository.
I understand that when I rebase a branch, it will base the commits in that branch to a different commit of where it originally branched off. I still have to merge the branch into my master branch. What actually happens when I do?
git checkout master
git fetch origin
git rebase origin/master
Wouldn't this rebase my local master branch into the remote master branch? I keep thinking of this picture.
Instead of feature I would have my local master branch and instead of Master, I would have the remote origin/master Branch. With the exception that Master doesn't really branches out origin/master.
Wouldn't this remove my local branch master? Wouldn't this move all my work into the "remote" repository? Also, I don't need to merge back before pushing it to the real remote repository?