Cannot pull because there are uncommitted changes using VS2015/Git
Asked Answered
N

1

5

Imagine the following scenario:

Manager has created a team project and decided to use (latest) git as VCS for the project. Developer team will be working using (latest) VS2015 (Enterprise) IDE. Manager has created a new (origin) branch called "master" and then committed & pushed 2 files to that branch.

Project file hierarchy:

  Project (Root) Folder
    | notes.txt
    \ readme.md

Developer team made of "Jym" and "Bennie" has pulled origin/master branch (and both of them are working on local/master branch). Jym has committed & pushed the first change to "notes.txt" file (directly to master branch). Bennie has created a new file called "todos.txt", and also was making some changes to "notes.txt" file. Now when Bennie tries to sync/pull changes (that were made earlier by Jym), the following message is displayed in Synchronization window:

Cannot pull because there are uncommitted changes. Commit or undo your changes before pulling again. See the Output window for details.

To make things a whole lot worse for the team, Bennie is also experiencing the exact same issue that was opened in late December last year. This means that Bennie is practically unable to run any git command (however, all features but "undo" seems to work fine with Visual Studio Git/TFS providers - which he have found really weird).
Also because of that, this question is not (possible) duplicate of another question.

How to solve the issue (from scenario described above) that Bennie is experiencing (using only Visual Studio of course)?

If there are any more details I can provide, please just post a comment.

EDIT 1 (output from suggested answer for solving "null" device):
Results from the first step: Isn't that a typo in that answer, shouldn't "nul" be "nil"?
See screenshot

Results from the second step (Device Manager): With View -> "Show hidden devices" option checked, there are no devices with small "warning" icon (unknown/unrecognized device) or "null" in any of devices' names.
Also, apparently "Non-Plug and Play Drivers" type is not even being listed (of course when View -> "Devices by type" is selected).

Results from the third step: %SystemRoot%\system32\drivers\null.sys file had existed and was deleted from the disk (copied and pasted in null.sys file from Windows 10).
More details: Once right-clicked any of those sys files, there is no "Install" nor "Uninstall" option in context menu, default action seems to be "Open with..." (which is bolded).

Results from fourth step: Attempt to merge null.reg failed. Reassigned owner of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\Root registry key, also set up appropriate permissions.
null.reg file was successfully merged into registry after updating registry key permissions.
Restarting a computer.
Waiting for the final answer ... Error still on show!
See screenshot

EDIT 2 (testing PATH environment variable):
See screenshot Same error still occurs (even after opening git-cmd.exe or git-bash.exe as administrator).

EDIT 3 (power options, not using "Allow the Computer to Enter Away Mode" setting):
Reference thread.
See screenshot

EDIT 4:
After Bennie has upgraded his machine from Windows 8.1 to 10, issue has been solved. We can now simply conclude that operating system was corrupted.

Nagle answered 31/1, 2016 at 7:52 Comment(13)
could you please provide extra details on whether Bennie has committed his (her?) changes ?Dulciedulcify
@AndreyPesoshin Bennie get "Cannot pull because there are uncommitted changes. Commit or undo your changes before pulling again. See the Output window for details." So he made changes locally one commit behind origin/master and unable to use git (or undo feature - for unknown reason). He tried reinstalling Git, Git for Windows (GitHub client), verifying that Git directory is set in PATH environment variable, etc. but git always responds with such/similar error message: "fatal: open /dev/null or dup failed: No such file or directory". He also tried using SourceTree, Tortoise... Nothing worked.Nagle
I mean Bennie can get the same error in case the changes are REALLY UNCOMMITTED and seen via git status as pending changes. So as far as I understood, the changes ARE committed into master just before the git pull command is tried to be executed?Dulciedulcify
@AndreyPesoshin Yes, of course there are uncommitted changes. No, the changes Bennie made locally are not committed nor pushed (he is stuck with his changes, 1 commit behind compared to origin/master). And Visual Studio has started to bug him now too, like if he creates a new file, it is not being tracked (added to included changes, same applies if he tries to permanently remove a file, like he's totally out-of-sync).Nagle
I've read your question once again with comment on details provided. Git normally wants changes to be first committed and only then synchronized with remote repositories. So if Bennie has a proper installation of git for Windows and/or VS2015, so he will be able to commit changes and then to pull and push (in this order) local state from and into the remote repository. If not - Bennie has to reinstall IDE and tools. Could you please try and return with the answer?Dulciedulcify
@AndreyPesoshin My team is open for solving this whatever it takes. Reinstalling OS is not an option. Core issue here is, "null" device. That I have just got a report about. See comments in VoC's answer. I will update Q with more details and a report about "null" device in a moment.Nagle
I'm talking about reinstalling Git for Windows (msysgit), not OS. Maybe there are screenshots or log information from git-cmd/msysgit to be added to the topic question?Dulciedulcify
@AndreyPesoshin I have updated Q. Added more information, outputs from each step (based on link that was added by VonC). Still not solved.Nagle
It seems like you have two very distinct issues here and this should be two separate questions. What version of VS 2015 are you running? Does this behavior change if you upgrade to the latest Quaterly Update?Fyke
@EdwardThomson Manager said it in the very beginning of the scenario. "Developer team will be working using (latest) VS2015 (Enterprise) IDE." Which is VS2015.1 (Update 1) with all necessary tools installed (3rd party Git extension, also installed msysgit, workspaces are configured, everything works fine in VS) and everything is up-to-date as of today. Just read it twice before posting comment, please? Because, I end up copy+pasting information I have already provided a few times that is already stated in the question (do 2+2).Nagle
Great! I see my advice to upgrade was a good one \o/Winterwinterbottom
@Winterwinterbottom @Nagle so, as we can see here, the Reinstalling OS is not an option was a false statement :)Dulciedulcify
@AndreyPesoshin Upgrade was the latest suitable option; reinstall (format/clean install) was not. There is a difference between the two ;)Nagle
W
13

Whenever a GUI (here a VS with Git integration) steps out of the nominal path (here a git push not immediately possible), revert to the git command line interface.

In your case, Bernie needs to a a git pull --rebase.

Open a git bash, and do (as Bernie)

cd /path/to/repo
git status # make sure everything is committed
git pull --rebase
git status # you see notes.txt as being in conflict
# edit notes.txt and resolve the conflict by removing merge markers
git add .
git rebase --continue

git push

Note, git pull --rebase might come soon to Got for Visual Studio (follow @gitforvs):

g4vs

Nothing official yet though.


Regarding "Couldn't open /dev/null (or dup failed)", see if "Getting errors when using GitHub for Windows" could help (issue with the null device).

IF the error persists though, as in git-for-windows/git issue 583, re-installing Windows remains the surest way to get out of this predicament.

As mentioned by the OP OmegaExtern in Edit 4, upgrading from win8 to win10 was enough to restore the device and solve the issue.

Winterwinterbottom answered 31/1, 2016 at 9:17 Comment(18)
This can't work out because "This means that Bennie is practically unable to run any git command". Read question once more?Nagle
@Nagle I have read it, and I am sure Bernie can run git commands in a shell. Just unzip github.com/git-for-windows/git/releases/download/… anywhere Bernie wants.Winterwinterbottom
Bennie runs Windows 8.1 (x86/32 bit). I have sent him 32bit portable zipped Git, and he then corrected environment variables (gitdir and path accordingly as mentioned in readme). When he runs git-bash executable as administrator, it shows command prompt and then it closes and there is a new file created called "mintty.exe.stackdump", here is contents of the file: gist.github.com/anonymous/…Nagle
@Nagle no need for git bash, the git-cmd.exe is enough. That will open a regular CMD session, which should work just fine.Winterwinterbottom
Ok, now he opened git-cmd.exe (as administrator). Well, same error message again: "fatal: open /dev/null or dup failed: No such file or directory".Nagle
@Nagle is the error message visible when the window opens, or in response of a git command (and if so, which one?)?Winterwinterbottom
It is in response to git command. Just typed "git" and hit return key, after that it responded with error message stated above.Nagle
@Nagle what about cd c:\path\to\repo and git status?Winterwinterbottom
@VoC Of course, batch commands and everything else works just fine. Personally I think this is something to do with the new update that was released lately in 2015, after he updated Git and GitHub, they just stopped working. Any git command fails with the error message, as I already said a few times.Nagle
@Nagle the next thing to test is to open a regular CMD, and type set PATH=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\path\to\PortableGit-2.7.0-32-bit\bin, and see if the issue persists with that simplified and minimal PATH.Winterwinterbottom
@Nagle in a git bash, can you try (as in github.com/progrium/busybox/issues/2#issue-36407815) touch /dev/null then git again?Winterwinterbottom
You have forgot one thing (read my second comment on your answer). When Bennie runs git-bash.exe (as admin), program/black window closes down almost instantaneously and a new file is written in root directory of portable git, that is next to git-bash.exe (called "mintty.exe.stackdump"): gist.github.com/anonymous/…Nagle
@Nagle And does it close as well when calling git-bash.exe from the CMD with the simplified path?Winterwinterbottom
@Nagle if it does... github.com/git-for-windows/git/issues/…, unfortunately.Winterwinterbottom
C:\Users\User\Downloads\PortableGit>git-bash.exe, opens a window for about 2 seconds later it closes, so yes in whatever case it closes/crashes. Reinstalling OS is not an option.Nagle
@Nagle Would it be an 'Away mode' issue? (social.technet.microsoft.com/Forums/windows/en-US/…)Winterwinterbottom
Updated Q (see edit #3). It is already set to other setting than "Allow the Computer to Enter Away Mode".Nagle
Let us continue this discussion in chat.Nagle

© 2022 - 2024 — McMap. All rights reserved.