As title. I have created a branch to do specific tasks add-ui-components. Unfortunately, I also found some specific changes, let's call it upgrade-webpack-config, that I want to move out of the current branch. The latter one I just named is a fake branch, as I have neither created a branch for it nor committed those changes. Given that I'm at the branch add-ui-components Is it possible that I can move those unstaged file changes back to the main so that I can create another branch for it after I'm done with the current branch add-ui-components? Thanks
Let me use some graph for better understanding
Input
main: A-B-C
feat: A-B-C-D-E + (not related unstaged changes)
Expected Output:
main: A-B-C + (not related unstaged changes)
feat: A-B-C-D-E + (new related changes added here)
featbranch: stash your changes:git stash --include-untrackedgit checkout maingit stash popgit commit -m "not related unstaged changes"git checkout featas the final step, you'll have to merge the "recent changes" in
maintofeat- either with a merge or a rebase.eg, for rebase:
git rebase main-> this will kinda revert all your commits and apply them one by one as if you had branchedfeatafter the "not related unstages changes" commit was applied tomain