gitvisual-studio-codemergefetchpull

Is there a simpler way to handle git conflicts in VSCode


I'm currently trying figure out Trunk Based Development with another team member:

Both of us are pushing directly to origin/master

When my teammate pushes, the repo in VSCode's Source Control Repositories will indicate I can Pull 1 commits from origin/master

Assuming we have modified the same file, clicking on the indicator will pop up a message: Please clean your repository working tree before checkout.

Right now, it's cumbersome as I have to stash away my changes, pull and then pop the stash etc and I'm not even certain if I lost any changes

My main question here is, how can I bring up the Merge Conflict Editor to deal with this. I tried googling, but wasn't able to find out how this could be done

Any ideas?


Solution

  • The (better) way I wanted to handle the conflict is known as Pull (Rebase) as mentioned by @orhtej2 (Thanks!), meaning, pulling down all the changes from origin/master and rebasing our changes on top of it

    Assuming that the origin/master is ahead of me, the exact steps would be as follows:

    1. Commit my changes locally first
    2. Source Control in VSCode will display the button Sync changes 1⬇ 1⬆
    3. Go to the of Source Control and click on Pull (Rebase)
    4. Source Control will list out the files that it does not know how to handle
    5. Clicking on any of the files will bring it up with the option to use the Merge Conflict Editor
    6. When all files are deconflicted (merged), go to Source Control and click on Continue
    7. That will push your deconflicted files to the origin/master

    UPDATE 2024-09-28

    For conflicts these days, what I prefer to do is to

    1. Undo my local unpushed commits until there are 0 unpushed using git reset --soft HEAD~1
    2. Examine how many files have conflict from git pull's errors
    3. It is usually only less than 5 files, so I will just make an in-memory copy and revert these 5 files for the pull to succeed
    4. Use my in-memory copy and replace these files
    5. At this point, it is very easy to see my own changes (A) and the other changes (B) that I have overwritten (Usually deleted)
    6. I will undo changes (B) and make sure changes (A) are not messing them up
    7. I prefer this as it is made up of simple operations, rather than looking at 3 different variants of the code at once