- Before adding new feature or a PR is merged at remote, at
main
branch:
git fetch
: get updates from remote repogit reset --hard origin/main
: sync localmain
to be the same as remotemain
; this can remove any changes at local, so should be called before adding any changes
- To create new features:
git checkout -b feature-name
: new a branch named "feature-name"- modify codes and commit
- (if at the same time remote
main
is changed due to another PR)git checkout main; git fetch; git reset --hard origin/main
thengit checkout feature-name; git rebase origin/main
and resolve any conflicts git push -u origin feature-name
for the first time to push a local branch to remote or simplygit push
if the branch already exists at remote
- Do pull request.