For a new feature I have created a branch in Git from the current dev branch (not master) and implemented some changes locally but without committing. Then I got sidetracked, and development has moved on. The branch I used as a base has been closed now, and there's a new one.
How can I change my feature branch so it's using the new dev branch as a base?
master --
\-- dev 1
\-- feature
\-- dev 2
I want to move feature now that it branched off to dev 2 and then commit my changes:
master ---
\-- dev 1
\-- dev 2
\-- feature
to the feature branch, without losing commits which others might have made, of course.
You need to
git rebase dev1 feature --onto dev2
(If I remember the arguments correctly, you may need dev1^
but I dont believe so).
Looks like you have to add your changes that are not commited yet on top of the dev2
branch. Please correct me if I'm mistaken.
git stash save -u "My feature" # stash all changes
git branch -d feature # delete old feature branch
git checkout dev2
git branch -b feature # create new feature branch
git stash apply # unstash all you changes
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.