I have seen a couple of different ways of using git rebase to commits from one branch to another branch. I don't know what the difference is between the two different methods for their end effect. I would like to know what the difference is.
One uses the rebase command twice but doesn't use the merge command. I found this process outlined here.
Another uses both the rebase and merge commands.
Things I have learned.
This section is to come later.
General Process for using the rebase command twice (source)
In this scenario I started a project in main and wanted to preserve what I had done as if I had done it in a feature branch instead of the main branch, so I wanted to move everything in the main branch to a new feature branch. The name of the feature branch in my case is . The goal is to move all of the commits from the main branch to the end of the main branch.
First checkout the first commit on the main branch.
git checkout <sha-1 of the specific commit>
Create the new feature banch that you want to move the commits to. This command both creates and swithches to the new branch.
git switch -c <Branch Name>
Switch back to the branch which is the source of the commits you want to bring to the new branch. In this case, the source branch is main.
git checkout main
Now use the rebase command to rebase to the destination branch. In this case the destination branch is cssmenu
git rebase cssmenu
Now switch back to the destination branch and rebase the source branch and push to the remote repository.
git checkout cssmenu
git rebase main
git push
What this seems to have done is duplicate all of the commits from the main branch onto the cssmenu branch. All three commits have been duplicated including the commit hashes for each one. I expected the hashes to be different, but they appear to be identical.