2

If I open a project in VS Code, or I change the branch I'm working on, a check happens to see if git pull or git push (git sync) for that branch is possible. If so, it is shown in the lower left corner:

enter image description here

However, I always forget to check this, so I start coding and get into conflicts when merging.

Is there an option in VS Code (or an extension) to give a popup warning when a git sync is possible?

Perneel
  • 3,317
  • 7
  • 45
  • 66

1 Answers1

0

You could simply set a pre-commit hook which would check if your local repo is in sync.

See for instance "Check if pull needed in Git".
It will be used with Git or Git in Visual Studio Code.

If your repo is not "in sync" with its remote counter-part (pull or push are possible), then the commit is refused.

That would force you to pull first.

Combine that "Can “git pull” automatically stash and pop pending changes?":

git config --global pull.rebase true
git config --global rebase.autoStash true

And your pull will automatically stash for you your work in progress, fetch, rebase your current commits on top of the updated branch, and re-apply your work in progress.
Then you can do a git commit.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250