Reputation: 186
I'm trying to implement a gitflow like workflow in my Azure DevOps hosted git repo. I've enabled CI/CD to my QA server that triggers from completion of pull request targeting the develop branch. Also, in ado, I've enabled pull request branch policy on develop so feature branches cannot be directly merged without a PR and code review. This all works except when pull request are completed they are leaving origin/develop behind local develop.
So right now if I:
git checkout develop
I see this message:
Your branch is ahead of 'origin/develop' by 11 commits.
So, under normal circumstances I think the fix for this is:
git push
or git push origin
-- from the develop branch.
But since there is a branch policy in force that requires a pull request, I cannot push. When I try to push develop, I get this message:
! [remote rejected] develop -> develop (TF402455: Pushes to this branch are not permitted; you must use a pull request to update this branch.)
Well, okay, I've done 11 pull requests to this branch already.
Any idea how to fix this?
Pull requests targeting develop should leave origin in sync with local.
EDIT: As mentioned in the comments I have disabled the branch policy that forces pull requests. Then I did a git push to clean up the situation. But here is the log from develop as requested below:
>git log
commit 545319a657801f3c279f727c53aa7d5b9d9f9d6e (HEAD -> develop, origin/develop, origin/master, origin/HEAD, master)
Merge: fe89f0a dad0fa3
Author: Ken Hadden <[email protected]>
Date: Thu Mar 28 18:09:32 2019 -0700
Merge branch 'master' into develop
commit fe89f0af4a9fe3848880854dbd88e3980e81bdb4
Merge: 9b37a92 c7fe732
Author: Ken Hadden <[email protected]>
Date: Thu Mar 28 12:15:48 2019 -0700
Merge branch 'develop' of https://mycompany.visualstudio.com/mycompany/_git/mycompany into develop
commit c7fe7329df9d40d0ed6db0ddf9f46ab5173aab85 (tag: 201)
Merge: 2386bbe c3b8468
Author: Ken Hadden <[email protected]>
Date: Mon Mar 25 20:50:07 2019 +0000
Merged PR 7: Build from PR test 3
commit 9b37a9238f369d0fd939b15446e2598a4b984cda
Merge: d3e27c1 c3b8468
Author: Ken Hadden <[email protected]>
Date: Mon Mar 25 13:41:12 2019 -0700
test 5
commit c3b8468f49d6426469699dcc19c01fc183823355
Author: Ken Hadden <[email protected]>
Date: Mon Mar 25 13:39:45 2019 -0700
test 4
commit d3e27c1b6abba1e0978a0c2673ebf5969ced37a0
Merge: 0415cf7 2386bbe
Author: Ken Hadden <[email protected]>
Date: Mon Mar 25 13:37:37 2019 -0700
Merge branch 'develop' of https://mycompany.visualstudio.com/mycompany/_git/mycompany into develop
commit 0415cf7f790770b9bc9e672a5998e85b0815ed46
Merge: 2ef8b41 6dc753e
Author: Ken Hadden <[email protected]>
Date: Mon Mar 25 13:34:27 2019 -0700
test 4
commit 6dc753eda1697b84a679d6105d2ef18a7f1d3043
:
Upvotes: 3
Views: 3740
Reputation: 2113
My experience is similar to the ones of @shayki Abramczyk and @Ken Hadden. What works for us is:
develop>
develop> git checkout -b feature/my-cool-new-feature
feature/my..> "Hello" > newfile.txt
feature/my..> git add -A
feature/my..> git commit -m "Add newfile.txt"
feature/my..> git push -u origin HEAD
Then I go to pull requests in Azure Devops and I get the option to create a PR out of my new branch that shows up there. When created, if I set it to auto-complete, then when it has been approved, built and tested ok it merges automatically to the target branch (in your case develop).
When "A-DOPS" is done, back at my machine I do:
feature/my..> git checkout develop
develop> git pull
And my local develop is in sync with the remote.
Upvotes: 2