This normally happens when you git commit
and try to git push
changes before git pulling
on that branch x
where someone else has already made changes.
The normal flow would be as below,
STEP 1: git stash
your local uncommitted changes on that branch.
STEP 2: git pull origin branch_name -v
to pull and mergepull and merge
to locally commitedcommitted changes on that branch, give the merge some message, and fix conflicts if any. (give this merge some message, and fix conflicts if any.)
STEP 3: git stash pop
the stash
ed changes. (Then you can make commits on popped files if you want or push already committed changes (STEP4) first and make new commit to files later.)
STEP 4: git push origin branch_name -v
the merged changes.
Replace branch_name
with master
(for master
branch).