I have an automated Jenkins job which simply does the following:
- pull from
remoteA - push into
remoteB
remoteA is the remote where developers actually push their code.
remoteB is never touched manually, it only receives udates trough that automated Job.
It worked well for a while, but now I get Updates were rejected because the tip of your current branch is behind its remote counterpart. when trying to push into remoteB
As far as I know, this happens when
- (a)
remoteBcontains changes whichremoteAdoesn't contain -> I think that's not possible because no human and no other Jenkins Job touches remoteB - (b) someone did a
rebaseon remoteA. -> As I am no git professional, I am very unsure how to deal with that scenario. Hope someone here can help.
git pull --rebase remoteB remoteAand then try to run job again. NOTE: check the log and verify the commits before proceedingremoteAandremoteBand to see what's different (do this withgit fetch origin/remoteB && git diff remoteA..origin/remoteB. You can also check theremoteAhistory and check if it has strange changes to it. As to how to fix the problem, you cat either whip-out the bazooka andgit push -f origin remoteBor do agit pull --rebase remoteB remoteAand then push to Brebaseor anamend). And you can only solve your problem with agit push --force-with-lease(if you want to keep the 'new' git history).