Git Merge

Merging git branches locally
Git
Author

Caleb Grant

Published

June 30, 2023

The steps below can be used to merge two branches on your local machine. The braches used in this example are:

  1. Pull main and dev branches so local repo is up to date with the remote.

    1. git checkout main
    2. git pull origin main
    3. git checkout dev
    4. git pull origin dev
  2. Checkout the main branch so we can merge the dev branch into main

    1. git checkout main
    2. git merge dev
    img
  3. Check the branch status: git status

    img
  4. Evaluate the two files with a conflict (ie. .gitignore and requirements.txt) and reconcile issues, then git add when ready.

  5. Commit the changes: git commit -m "merge @tnelson-integral dev branch with main"

  6. Push changes to the remote on GitHub: git push origin main

  7. Check out the dev branch locally and pull the main branch changes into it so dev can be up-to-date with main

    1. git checkout dev
    2. git pull origin main
    3. git push origin dev