When working with branches, here is the general workflow to adhere to.
-
Before starting work:
# always start your branching from the main branch git checkout main # pull the latest git pull # create a new branch, branch-ed off of the main branch git checkout -b my-awesome-feature
-
Commit changes and push to your branch in GitHub regularly.
# add files to the staging area git add filename1 git add filename2 git add filename3 # commit with a descritive message git commit -m "descriptive message of the change i just made" # push to your branch on GitHub git push
-
Also make sure to periodically pull from main:
git pull origin main
Pulling from main periodically is very important! This will keep your code relatively in-sync and prevent deferring massive merge conflicts down the line.
-
When you're done with your work
# makes sure you've commited and pushed # all the changes to your branch in GitHub git status
then open up GitHub and issue a pull request back to main.
The feature branch workflow is where every small or large feature gets its own branch. These branches are shortlived and are quickly merged back into main. Each feature branch corresponds to a pull request and the branch is deleted after the PR is merged.
The team member workflow is where each team member gets their own branch. These branches stay alive throughout the duration of the project and can be merged back in as frequently as you like. In this approach you can only have one PR open at a given time per team member.