简体   繁体   中英

Git Extension for Visual Studio

I am new to git and I'm using git extension for Visual Studio. When other team members commit changes sometimes when I try to sync the project I can see the incoming commits but the project is not synced and the error below is raised.

An error was raised by libgit2. Category = 21 (MergeConflict). 2 uncommitted changes would be overwritten by merge

the problem is that how can I merge conflicts? There is no window for merging conflicts after this error is raised and I have also committed all my changes.

The message is about uncommitted changes, not real merge conflicts. Learn to NOT merge or do any fancy git stuff with uncommitted changes. Before an operation commit your changes or stash them. Even if conflict like that is not flagged it's likely not what you really wanted to do.

In GE there's an option to show worktree changes (ignore the "slow" warning unless you work on a giant repo and regularly have hundreds of changed files) and get used to look at it in browse. Also the "Commit" button shows a count, that shall be 0 when you incite a merge.

If in the middle of your work you want to synch (and thought again and have a really good reason, honest), use stash , then pull (or rebase), and after that is done, unstash your work.

Real merge conflicts are best handled using visual merge tools, you can try tortoisemerge, or my favorite, sourcegear's diffmerge. Kdiff3 that is shipped with GE is good to look around but not so good at resolve itself, unless all you need is pick candidates literally. GE puts you to conflict resolution automaticly.

The earlier answer is not always true. You can get this message even when you don't have any uncommitted changes. My coworker & I both fixed a bug, and committed to our local repos, and I like his better. I never checked in my change, but undid it & pulled his change.

Meanwhile, he had "reverted" his change (without talking to me) and then asked me to push my change up. I told him I'd tossed my change, so he reverted his revert (ending up with two commits).

When I went to push a different change (committed to my local repo with no uncommitted changes), he'd pushed both the reversion of his change and the re-reversion, and I got the message above.

The solution was pretty simple, I used the Actions menu to open the command prompt and issued a git pull there. That worked correctly and created a merge commit for me with his reversion and re-reversion.

Yes, he could have ( insert incomprehensible git-gibberish here ) instead, but he didn't, so suck it nerds. It works, we're moving on.

Here's a VS feedback item regarding this issue: http://connect.microsoft.com/VisualStudio/feedbackdetail/view/955248/git-merge-fails-claiming-uncommited-change-would-be-overwritten-by-merge-ssh-mergeconflict

Sometimes, git pull isn't enough... (if you get "Already up to date.")

It may be necessary to do the merge from the command line:

In Visual Studio (2015, Update 3 for me) in the Team Explorer , Branches , Actions , Open In Command Prompt , then:

git merge NameOfBranchBeingMergedFrom

Then close that window and do the rest (Merge Conflicts, etc) from VS

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM