This is the git workflow I use that allows multiple people to collaborate on the same Git(Hub) repository.
You should start this when you do not have any local changes (your code on your computer and GitHub is the same).
I like to prefix my branches with an indicaton of what it is, for example feat/ for features, fix/ for bug fixes, doc/ for documentation changes. I also only use lowercase with - for the branch name.
git switch -c feat/metered-paymentsKeep your changes brief. I aim to stay under 200 lines of code per PR. Once you have some local changes, stage them with git add -A or git add -p followed with a git add -A. I don't use git add . because if you aren't in the root directory of your project, you might miss some files.
Commit your changes git commit -m "implement metered payments". Repeat as many times as you need.
Once you made all your changes, push them with git push.
Git may tell you that the remote branch doesn't exist. It will give you a command to push and create the remote branch, but I have the following set in my git config (~/.config/git/config) so it does that automatically.
[push]
autoSetupRemote = true
Once your new code is pushed on a separate branch on GitHub, make a Pull Request (PR) from your branch (feat/metered-payments) to your main branch (main). This is a good place for teammates/co-workers/you to review your code.
Once it's reviewed, select "Squash and Merge", which squashes all the commits from your PR into a single one, making navigating past commits easier.
You can delete the remote branch if you want.
Now we want to sync our local git repo.
git switch main
git pulland we can remove the old branch.
git fetch --all --pruneNow you are back to before 1), so you can repeat the process.