Branch from main
git checkout main
git pull
git checkout -b <branch-name>
Rebase upstream often to avoid conflicts
git fetch origin
git rebase origin/main
In case of multiple commits rebase interactively
git rebase -i origin/main
Commit with the perfect commit message
Rebase from main
git fetch origin
git rebase -i origin/main
Force push your branch
git push --force-with-lease origin <branch-name>
View a list of new commits. View changed files. Merge branch into main.
git log origin/main..<branch-name>
git diff --stat origin/main
git checkout main
git merge <branch-name> --ff-only
git push