Git Merge without removing the other branch to pull the changes

I searched a lot but was not able to find a confident solution(pardon me as I am new to git and maybe I didn’t get some term well). So I will state my exact problem here:

  1. I have a software (say in branch main) of which I just released v5.0 and then I created a new branch (say 5b) to fix all the issues that come in the branch.

  2. beyond compare with `git difftool --dir-diff` — Hitting an issue with sym-links
  3. git push fails with git-credential-winstore
  4. IntelliJ Idea: Disable Auto Commit on Merge
  5. How to clone only a folder from a git submodule?
  6. Git for Windows - The Program can't start because libiconv2.dll is missing
  7. How to handle xml/html in git feature branch workflow?
  8. All the new features are being added to main branch.

  9. Now I have to supply a build with the new features to someone, but I also want to have all the bugfixes.

  10. My logic says that I can pull all the changes from 5b, merge it with main and make a build.

The only problem is that I want to keep that branch 5b as it is so that other fixes can be added to it. While in the main, all the changes from 5b should be available.

Please let me know how to accomplish this. A step wise answer with a bit of detail will be really helpful.

Thanks,

  • write git commit version info in app's footer
  • Git: Manage each version of my app?
  • Using the android repo tool for a personal project
  • git push origin master: ERROR: Disconnected: No supported authentication methods available
  • Git ignores deleted file on merge
  • GIT: Appending a patch made after a few commits
  • One Solution collect form web for “Git Merge without removing the other branch to pull the changes”

    You have a branch – main

    You have a branch with bug fixes – 5b

    Now in order to merge your bug fixes changes to main,

    pull latest changes from main branch:

     git checkout main
     git pull origin main
    

    merge the changes in main branch to 5b branch (5b branch is up to date with main branch):

     git checkout 5b
     git pull origin 5b
     git merge main
     git push origin 5b
    

    merge your 5b branch changes back to main:

     git checkout main
     git merge 5b
     git push origin main
    

    This will not remove your 5b(bug_fixes) branch or main branch. you can keep merging your bug fixes branch changes to main this way.

    Git Baby is a git and github fan, let's start git clone.