We have a few branches...
master
is our dev branch.feature-newfeature
is a new feature.feature-tempfeature
is a new feature that our product team have asked for until new feature is created. feature-newfeature
was started a while ago and hasn't been merged into master
yet (but there have been other changes to master
).We have now been instructed to put this temp feature in which needs all the changes from master
- so its a releasable build - but also needs some of the stuff we've been working on in newfeature
(as they say "you can reuse some of the stuff you've already done").
How would it be best to go about doing this? I have created feature-tempfeature
from the master
branch. feature-newfeature
isn't finished, and I don't want to merge it into master.
I don't want to just use feature-newfeature
either because we want to be able to keep working on that in parallel.
How would you sort out this issue in your dev environment?
Many thanks!
branches are just aliases for a specific commit. Therefore you can have multiple branches that actually point to the same commit. So, what you could do is to create a new branch newBranch
that points to the same commit as master and then merge feature-tempfeature
into newBranch
. The effect would be the same as merging into master, except that master stays untouched.
From my understanding your scenario is:
---master----
\___tempf____
\___newf_____
Your problem: You need tempf
with changes of master
as well as newf
so
Solution:
1) Stash your unsaved changes in tempf
with $ git stash
2) Merge master with tempf and merge newf with tempf to have the changes of the both master and newf
3) Stash pop your changes with $ git stash pop
And as @MaxLeske said, branches are just aliases, they serve just like pointer to a commit but are not the commits themselves.
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