"Todd A. Jacobs" already mentioned "rebase" is the concept here. This is just a more detailed way of doing things.
Let's say you're on the master branch
$ git branch
* master
You want to make a fix, so create a “fixbranch” which is branched from the master
$ git checkout -b fixbranch
Maybe you would have worked for a couple of days on this branch and had a couple of commits.
The day you wanted to push your commits to central master repo! Checkout master and get the latest changes from the central master repo
$ git checkout master
$ git pull origin master
Rebase your fixbranch with the master to have a clean history and resolve the conflicts if any in the local repo itself.
$ git checkout fixbranch
$ git rebase master
Now fixbranch is uptodate to with the central master, let me merge fixbranch into the master branch
$ git checkout master
$ git merge fixbranch
I’m done! let me push local master to the central master
$ git push origin master
https://git-scm.com/book/en/v2/Git-Branching-Rebasing