As a new git user, I am confused with following steps. I was told to do following when I create my new feature branch
first make sure you got latest changes from remote (git fetch / git merge)
create new branch my-branch and check it out
make change
git add . //stage changes
git commit -m "my message"
repeate above as many times as needed
Then when ready to push my completed work to remote, make sure you got the latest remote changes into your new branch my-branch
git fetch origin //get latest changes from origin
git merge origin/my-branch // merge the latest changes on remote into my-branch
git push origin my-branch // push my branch to remote
But reading a git tutorial, I see they recommend to push new branch to origin right after creating it using
git push -u origin my-branch
then work on your changes, stage, commit
then push like this
git push
Am I being told to do it incorrectly?
Which method is better and why?