In my case for exact same error, I was not the only developer as well.
So I went to commit & push my changes at same time, seen at bottom of the Commit
dialog popup:
![Checked option for: Push changes immediately to origin](https://i.stack.imgur.com/JOd7p.png)
...but I made the huge mistake of forgetting to hit the Fetch
button to see if I have latest, which I did not.
The commit successfully executed, however not the push, but instead gives the same mentioned error;
...even though other developers didn't alter same files as me, I cannot pull latest as same error is presented.
The GUI Solution
Most of the time I prefer sticking with Sourcetree's GUI (Graphical User Interface). This solution might not be ideal, however this is what got things going again for me without worrying that I may lose my changes or compromise more recent updates from other developers.
STEP 1
Right-click on the commit right before yours to undo your locally committed changes and select Reset current branch to this commit
like so:
![Sourcetree window with right-clicked commit and selecting: Reset current branch to this commit](https://i.stack.imgur.com/9yatL.png)
STEP 2
Once all the loading spinners disappear and Sourcetree is done loading the previous commit, at the top-left of window, click on Pull
button...
![Sourcetree window with with the Pull button highlighted](https://i.stack.imgur.com/fGL0e.png)
...then a dialog popup will appear, and click the OK
button at bottom-right:
![Sourcetree window dialog popup with the OK button highlighted](https://i.stack.imgur.com/lYmaI.png)
STEP 3
After pulling latest, if you do not get any errors, skip to STEP 4 (next step below). Otherwise if you discover any merge conflicts at this point, like I did with my Web.config
file:
![Sourcetree window showing the error hint: Updates were rejected because the tip of your current branch is behind](https://i.stack.imgur.com/5nD9p.png)
...then click on the Stash
button at the top, a dialog popup will appear and you will need to write a Descriptive-name-of-your-changes, then click the OK
button:
![Sourcetree window with Stash button highlighted and dialog popup showing input to name your stash with OK button highlighted](https://i.stack.imgur.com/wPC1I.png)
...once Sourcetree is done stashing your altered file(s), repeat actions in STEP 2 (previous step above), and then your local files will have latest changes. Now your changes can be reapplied by opening your STASHES
seen at bottom of Sourcetree left column, use the arrow to expand your stashes, then right-click to choose Apply Stash 'Descriptive-name-of-your-changes'
, and after select OK
button in dialog popup that appears:
![Sourcetree window with the Stashes section expanded and changes right-clicked with Apply Stash highlighted](https://i.stack.imgur.com/sAtdU.png)
![Sourcetree dialog popup ask your to confirm if you would like to apply stash you your local copy](https://i.stack.imgur.com/svikL.png)
IF you have any Merge Conflict(s) right now, go to your preferred text-editor, like Visual Studio Code, and in the affected files select the Accept Incoming Change
link, then save:
![enter image description here](https://i.stack.imgur.com/6hzcE.png)
Then back to Sourcetree, click on the Commit
button at top:
![enter image description here](https://i.stack.imgur.com/HQgzc.png)
then right-click on the conflicted file(s), and under Resolve Conflicts
select the Mark Resolved
option:
![enter image description here](https://i.stack.imgur.com/gMYOo.png)
STEP 4
Finally!!! We are now able to commit our file(s), also checkmark the Push changes immediately to origin
option before clicking the Commit
button:
![enter image description here](https://i.stack.imgur.com/2hgR0.png)
P.S. while writing this, a commit was submitted by another developer right before I got to commit, so had to pretty much repeat steps.