2 years ago

#44954

test-img

Hazel へいぜる

Prevent local branch from pushing to upstream branch in DevOps using VSCode?

I have three branches (in DevOps), A, B, and C. In my case, A is the main, B is a development trunkline, and C is a feature being developed for B.

While working on C, I'd like to be pulling changes from B when I fetch and pull. However, when I push, I only want to push to C. I want to be forced to create pull requests to merge C back into B.

After doing some reading, I learned that I could set B as the upstream of C like I would be used to seeing with a forked repository on GitHub. I utilized the following command to do so:

git branch --set-upstream-to origin/B

However, this doesn't just pull from B, it also pushes changes to B when I use Visual Studio Code's sync changes button:

Screenshot of the sync changes button for reference.

How do I ensure that a push, only pushes changes to the repository for C, while pulls will pull changes from B?

git

visual-studio-code

azure-devops

branching-and-merging

upstream-branch

0 Answers

Your Answer

Accepted video resources