If A and B are working on the same git repo and A pushes a change on a feature branch: A-feature
to the repo BEFORE B, B now needs to do a pull before he can push.
But where are the exact condition for this described? E.g. does it apply to any change on any branch pushed to the repo? Or is it only if A and B are pushing to the same branch? Meaning that B could push to B-feature
even though A just pushed on A-feature
before him?
Meaning that B could push to B-feature even though A just pushed on A-feature before him?
Yes. The warning you get is only when you are pushing to a branch updated by someone else:
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
The only alternative to a git pull
would be a git push --force
(which would overwrite the history published by A
with B
's, if B
were to push on A-feature
, and that is bad.).
See "git push --force
, behind the scenes".
If nobody but B
is working on B-feature
, no pull is needed when B
wants to push the local B-feature
branch to the upstream repo: the push will be a fast-forward one: you are adding new commits on top of the remote branch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With