Merging
Merging means combining the changes from one branch into another. It's a fundamental operation in Git that allows you to integrate different lines of development and bring work from feature branches back into the main codebase.
Use Cases:
Examples:

How to Merge

  1. Switch to the branch you want to merge into (usually main):
    git switch main
  2. Update your branch with the latest changes before merging:
    git pull
    You should ensure that the branch you switched to is updated with the latest changes from the repo before merging.
  3. Merge a branch into your current branch:
    git merge [target branch]
    This merges the "demo1" branch into your current branch.

Squash Merging

Squash merge is used if you want all changes from a specific branch to your current branch in a single commit.

How to Squash Merge

  1. Create a new branch and switch over.
  2. Make changes such as change text, add new files, etc.
  3. Commit those changes.
  4. Switch back to your main branch.
  5. Use git command:
    git merge --squash [target branch]
You may notice that this DID NOT merge together. It simply copied all the changes made in your new branch and pasted it in your main branch and then you can manually commit those changes in the main branch. This keeps the project history clean and easy to read.

Abort Merging

Aborting a merge will cancel a merge that is currently in progress and returns the repo to the state it was before the merge started.
git merge --abort
This is handy if you have any issues during a merge like a conflict that you don't want to resolve.