Start with your main branch

git checkout main
git fetch origin

If your local main has been modified, you can reset its state.

git reset --hard origin/main

Checkout a new feature branch.

git checkout -b my-feature

Make changes in this branch, committing as usual.

git add file.txt
git commit -m "add my file.txt"

You can push your branch to allow others and yourself to evaluate and commit further to it.

git push -u origin my-feature

It’s time to test, review, get approval, etc. for your branch to be merged into main!

Now we merge my-feature into main:

git checkout main
git pull
git pull origin my-feature
git push

Here we checkout main, making sure to be at the latest revision with git pull. Next you pull in the changes from the my-feature branch, git pull is shorthand for running git fetch followed by git merge. So if there aren’t any conflicts, your main should now include the commits from my-feature.

Finally you git push your updated local main to your origin.