-
Notifications
You must be signed in to change notification settings - Fork 0
Using GitHub branches and PR
The github structure is defined to have master branches for each feature so multiple people can work on the same feature and create PR's to this master feature branch to reduce conflicts when merging code.
When feature branches (<master-feature>
) are complete, that feature can be pushed to the main
(default) branch.
The general process goes as follows:
-
clone the repo
git clone <repo>
Skip if you have already cloned the repo
-
switch to the master branch you'd like to work on
git checkout <master-feature>
-
create (
checkout -b
) your own personal branch from thisgit checkout -b <name>-<short_description>
Note: You can make a PR later to merge it into the master feature branch
-
develop as you would normally on your personal branch
- make changes to code
-
git add .
to add all files from your current directory, including those in sub-directories git commit -m "commit message here"
-
git push
to push to your remote branch of the same name on GitHub.
Tip: commit often to your branch and push so people can see what you are doing
When you are reasonably sure the code for the function you are implementing is working:
-
create a PR (on GitHub) from your branch into the master feature branch you are working on.
<master-feature> <- <your-branch>
at topNote: If you aren't sure about your code you can create a PR or draft PR and someone can easily review the changes you've made.
-
Once you have merged your local branch into the
<master-feature>
, you can delete your local copy (optional) andcheckout
a new copy of the<master-feature>
branch you want to work on.
Then repeat the above Workflow steps to (1) create a new local branch for the next function/issue you are working on and (2) create a new PR when you are done.
If main or the master branch has changes you'd like to merge into your local branch, you can use:
-
git pull origin main
while in your branch to get the latest changes from main. - Or
git pull origin <master-feature>
if you want to pull the latest changes from the feature branch to your personal branch.
git checkout main
to switch to the main
branch.