This has happened because some changes have been pushed to the remote branch since you last downloaded it. Your local branch was not up-to-date with the remote branch. You have to bring them to the same level and then push your local branch to the remote repository.
This can be done using either of them:
1. Fetch + Rebase:
git fetch
git rebase origin/branch_name
There are 2 steps in this approach. You first fetch all the changes made in the remote repository. After fetching, you then rebase your branch with the remote branch.
2. Fetch + Merge
git fetch
git merge origin/branch_name
In this, you first fetch all the changes but instead of rebasing, you merge the remote changes onto your local branch.
3. Pull
git pull
It is basically git fetch
followed by git merge
in a single command. You can use this command and git will automatically perform a fetch and then merge the remote changes into your local branch.
4. Pull with Rebase
git pull --rebase origin branch_name
This tells git that rebase be used instead of merge. Git will fetch first and then rebase the remote changes with your local changes.
After this has been done, some conflicts may occur. Resolve this conflicts and then you can push the changes to remote repository using the below command.
git push origin branch_name
For merge vs rebase: When do you use git rebase instead of git merge?