Use this basic workflow when making changes:
- Create a new branch for your work.
- Make your code changes on that branch.
- Commit and push the branch to GitHub.
- Merge the branch into the main branch when the work is done.
Be careful with unstaged changes.
Before switching branches or pulling, check your work:
git statusIf you have unfinished changes, commit them or stash them first.
Start from the main branch and make sure it is up to date:
git checkout main
git pull origin mainWarning: do not run these commands if you have unstaged changes you want to keep. Check git status first.
Create and switch to a new branch:
git checkout -b your-branch-nameUse a clear branch name, for example:
feature/login-page
fix/navbar-bugAfter making changes, stage and commit them:
git add .
git commit -m "Describe your changes"Push the branch to GitHub:
git push -u origin your-branch-nameThe -u links your local branch to the remote branch so future pushes can use:
git pushWhen the branch is ready, merge it into main using a pull request.
- Open the repository on GitHub.
- Create a pull request from
your-branch-nameintomain. - Review the changes.
- Merge the pull request on GitHub.
git status
git checkout main
git pull origin main
git checkout -b your-branch-name
# make changes
git add .
git commit -m "Describe your changes"
git push -u origin your-branch-name
# when done
# open a pull request on GitHub and merge into main