Assume I have a master branch with some commits I want to keep for later documentation and reference but remove them from the master (because I want the master to be on the same state as the upstream repo).
My approach now is, to
- Create a new branch from current master state
- Reset (--hard) the master to a state which is present in the upstream repo as well
Now, my question is:
- What happens to the new branch when removing the reference commit from the master?
- Or am I completely wrong in the understanding of how branches are referenced.
Often branches are shown in the following way, where (to my understanding) D
is the basis of the new branch.
A - B - C - D (master)
\
(new branch)
Is the branch "rebased" automatically or how would you call it? Would it then look like this?
A - B (master)
\
C - D (new branch)
Last and maybe most general question:
- Is my approach of keeping the state in a new branch and
reset --hard
the master branch the right way to achieve my goal of getting my fork back to the upstream state (commitB
) without having my commits (C
andD
) merged?