DEV Community

Mal
Mal

Posted on • Updated on

GitHub Workflow 101

How to fix bugs or add features on personal branch and then merge with main branch successfully

The GitHub workflow is how developers add features to code and test them without disrupting the main branch. It is important to memorize this process since developers use it frequently. By the end of my coding bootcamp I will know these commands in my sleep!

Instructions for MacOS terminal

  1. Use git status in MacOS terminal to check which branch you are operating in
    Returns:
    On branch main
    Your branch is up to date with 'origin/main'.

  2. Create a new branch with git checkout -b prefix/description
    Returns: Switched to a new branch 'prefix/description'

  3. Verify you are in the correct branch with git status
    Returns: On branch prefix/description

  4. Add code changes to personal branch git add -A

  5. Create commit and describe changes git commit -m "enter description"

  6. Double check that your branch is updated with most recent version with git pull origin main

  7. Push changes from local branch to remote branch with git push origin prefix/description

  8. Create a pull request

  • Open GitHub repo in browser
  • Select Compare and pull request (green)
  • Add descriptive title and comment about changes
  • Select Create pull request (green)
  • Once pull request has been approved by teammates

LAST STEPS!

  1. Confirm there are no conflicts with main and personal branch
  2. Merge Pull Request
  3. Delete personal branch
  4. Open MacOS Terminal
  5. git checkout main to switch back to main branch
  6. git pull origin main to update merge on local device

That's it!

These are the basic commands to create a new branch, make changes to code, push changes to remote branch, create a pull request, and merge with main branch. You will use these daily as a developer

Top comments (0)