$ git init
$ git add -A
$ git commit -m "init"
$ git branch -M main
# add remote repo with default user
$ git remote add origin git@github.com:organization/project.git
# or with a specific user account already prepared (check how to manage multiple GitHub accounts..)
$ git remote add origin git@user:organization/project.git
# push to remote main
$ git push -u origin main
# or download the main branch from remote
$ git pull origin main
# create feature branch
$ git branch feature_one
$ git checkout feature_one
# ..
# .. make all necessary developments ..
# ..
# commit all in the current branch
$ git add -A && git commit -m "new: feature dev."
# switch to main branch && pull main from remote origin to check if
$ git branch main && git pull origin main
# switch to dev branch and merge to be sure that everything is OK
$ git branch main
$ git merge main
# in case of conflicts, fix them and commit once again
# and push to remote
$ git push
# will be suggested the right cmd in case if the branch is a new one and does not exists on remote, like:
$ git push --set-upstream origin feature_one
# wait for team lead comments on github.com. if so - make related changes and repeat previous dev steps
# on github.com:
- create pull request
- merge pull request (or rebase & merge)
- it's preferable to delete currently merged branch
Some useful commands:
# use stash command to switch between branches while developing..
$ git stash
# after switching between branches, to return the stashed staged & unstaged files back:
$ git stash pop
# check current remote repo
$ git remote show origin
# remove remote repo
$ git remote remove origin
# delete local branch
$ git branch -d <branch_name>
# delete remote branch
$ git push <remote_name> :<branch_name>
@source: https://docs.github.com/en/get-started/quickstart/hello-world