Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pull and rebase from another branch in Visual Studio Code?

I am putting together a workflow where my team will be pulling and rebasing from the upstream repository after submitting a Pull Request and having it be merged. We are not using branching1, and so I would like to have instructions available for pulling in the lastest upstream master. However, VSCode only lets me pull from a specific remote and branch (thus producing an unwanted merge commit), or pull + rebase from origin/master, which is also undesirable because the point is that pulling from upstream/master is the goal.

Visual Studio Code Command Palette displaying "Git: Pull from...", "Git: Pull (Rebase)", and "Git: Pull"

enter image description here


1 This is not a professional environment, with people who are unfamiliar with Git, so I would like to keep the version control work as simple as possible.
like image 531
Koopa Avatar asked Oct 28 '25 05:10

Koopa


2 Answers

I'm settling for enforcing a workflow that does make use of branches, and uses the Git CLI when necessary, because Visual Studio Code does not offer all of the Git commands directly. In particular, I'm using the option in VSCode to set the default terminal to Git Bash, and having my team toggle the integrated terminal. My final instructions look like:

  • Ensure you're on the branch with your own changes.
  • Toggle the integrated terminal in VSCode.
  • Run git rebase upstream/master.
  • Resolve any merge conflicts that come up.
  • Run the Git: Push command, emphasis on not using the Synchronize Changes button in the UI, because this will both push and pull, making a mess (an unneeded merge commit is created, in this event).
like image 150
Koopa Avatar answered Oct 30 '25 21:10

Koopa


To rebase the branch using VSCode, you can:

  1. Use the command palette and type "rebase branch"

enter image description here

  1. Or by using the source control and go in the Branch section

enter image description here

like image 21
greguintow Avatar answered Oct 30 '25 22:10

greguintow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!