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
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'.
Create a new branch with
git checkout -b prefix/description
Returns:Switched to a new branch 'prefix/description'
Verify you are in the correct branch with
git status
Returns:On branch prefix/description
Add code changes to personal branch
git add -A
Create commit and describe changes
git commit -m "enter description"
Double check that your branch is updated with most recent version with
git pull origin main
Push changes from local branch to remote branch with
git push origin prefix/description
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!
- Confirm there are no conflicts with main and personal branch
Merge Pull Request
- Delete personal branch
- Open MacOS Terminal
-
git checkout main
to switch back to main branch -
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)