There exists a master branch and develop branch. They both have a different sets of commits. (I think I’m right to say that these branches have diverged) I accidentally created a feature branch off of the develop branch, made a commit, and pushed it to the remote repo. In this case, the code changes from the previous commits on master and develop do not affect the commit on the feature branch, so I should be able to move these code changes onto the master branch. How would I go about doing this in a proper git way?
chatgpt is suggesting:
git checkout feature
git rebase master
git push origin feature --force
However, after I rebase, vscode is showing option to sync incoming/outgoing commits from develop branch. These are all the changes that I’ve made on the develop branch that I don’t want on main just yet.
What I ended up doing is deleting the branch completely off of both local and remote repos, then going into local master, create the feature branch and redo the code update.
Instead of deleting branches and starting over, per chatgpt, I could have created a new feature branch locally off the master branch, cherry picked the commit from the old feature branch, then run git push origin feature-new:feature --force
to replace the old branch.
Any insight would be helpful – specifically about the incoming/outgoing extra commits after rebasing.