1

I'm referring to Git, as used by the GUI in VS Community 2022.

It seems like a simple question, but it doesn't look like anyone else has asked this question.

If you need more details, please ask. Please don't just ignore this question. Thanks.

  • 1
    What do you mean by "get `git` to view project files"? git isn't a file viewer... – Dai Feb 08 '22 at 04:28
  • Are you asking how to add the project's files into a Git repository from within the VS built-in GUI or what is the question? – heap underrun Feb 08 '22 at 04:36
  • I mean, to get Git to recognize a file as 'unstaged', so that it can be staged. The 'git changes' viewer says there's no unstaged changes in the working directory, even though I changed and saved a source code file. So maybe my question could be rephrased as, "How do I place files in the working directory?" or "how do I tangibly view the working directory?" Answer to either might help – Computerized Free Will Feb 08 '22 at 05:16

1 Answers1

0

The 'git changes' viewer says there's no unstaged changes in the working directory, even though I changed and saved a source code file

Fall back temporarily to command-line, and check your file is not ignored:

cd /path/to/repository
git check-ignore -v -- folder/modified/file

Double-check also the icon overlay symbol on those files, as shown here.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • New problem - cmd prompt on my pc doesn't even recognize git as a file. I don't know how to get git to run on it. I installed git – Computerized Free Will Feb 09 '22 at 06:40
  • @nofreewill That is a PATH issue. Check your %PATH% user environment variable: https://stackoverflow.com/a/53706956/6309 – VonC Feb 09 '22 at 06:45
  • Below are my sys paths. Are there any new ones I should include or delete for whatever reason? PATH 1 C:\Users\User\AppData\Local\Microsoft\WindowsApps PATH 2 C:\Users\User\AppData\Roaming\npm PATH 3 C:\Program Files (x86)\FAHClient PATH 4 A:\Apps\SocketeQ\windowsandroid_root\system\bin PATH 5 A:\Apps\SocketeQ\windowsandroid_root\system\lib PATH 6 C:\Users\User\AppData\Local\atom\bin PATH 7 %USERPROFILE%\.dotnet\tools ------ EDIT: Why comments in stack don't allow new line characters is beyond me. – Computerized Free Will Feb 10 '22 at 05:58
  • @nofreewill check also your User environment variable PATH, as the PATH is the concatenation of both system and user. But make sure you see `C:\Program Files\Git\bin`, assuming you have installed Git for Windows https://github.com/git-for-windows/git/releases – VonC Feb 10 '22 at 07:21
  • I had "C:\Program Files\Git\mingw64\bin" and "C:\Program Files\Git\usr\bin" but not Git/bin. Strange – Computerized Free Will Feb 11 '22 at 06:26
  • 1
    @nofreewill Exactly: add `Git\bin`, and git should be recognized. – VonC Feb 11 '22 at 06:40
  • So I did the git ignore check on the file that I want to stage - and it gives this message.... ---- error: unknown option `consoleapplication1.cpp' The dir for the file as so named is src, not .git - should it be in .git? Should src be in .git? How do I get .git to interact (I'm guessing this was the repo that init)? – Computerized Free Will Feb 11 '22 at 06:46
  • @nofreewill nothing should be in .git. This just means the command was incorrect. Try, in the parent folder of .git, where you see src: `git check-ignore -v -- src/consoleapplication1.cpp` (or `src/path/to/consoleapplication1.cpp`: I do not know where `consoleapplication1.cpp` is, under `src`) – VonC Feb 11 '22 at 07:11
  • The file is right in src and I'm doing it from the parent directory of src, and I typed in the path as you said ('src/filename'), but i still get the 'unknown option' error. If I put in a space like so '- v -- src/filename' it instead returns no information at all, and just goes to the new input line. – Computerized Free Will Feb 12 '22 at 07:49
  • @nof there is no space between - and v: it is -v, not - v. – VonC Feb 12 '22 at 08:50
  • I didn't have a space in -v. Must have been an typo in the comment – Computerized Free Will Feb 13 '22 at 08:01
  • @nofreewill " I do not know where `consoleapplication1.cpp` is, under `src/`": the idea of `git check-ignore` is to check if a given file is ignored: you need to know the exact path of that file under `src/`. – VonC Feb 13 '22 at 11:15
  • I said the file is right under src. If you don't want to help, fine, I'll learn some other way. – Computerized Free Will Feb 14 '22 at 02:48
  • @nofreewill Strange then. Not sure why the "unknown option" comes from. What version of Git for windows are you using? – VonC Feb 14 '22 at 07:40
  • @nofreewill Just in case, can you do a `git update-git-for-windows`? (to switch to `2.35.1.windows.2`) – VonC Feb 16 '22 at 06:46
  • Alright, I updated to windows.2 (checked version to make sure). Now I type in git check-ignore -v -- src/ConsoleApplication1.cpp and nothing happens still – Computerized Free Will Feb 16 '22 at 15:03
  • error: pathspec 'consoleapplication1.cpp' did not match any file(s) known to git ------ I cd into src as well – Computerized Free Will Feb 16 '22 at 15:12
  • @nofreewill Is it possible the file was renamed from `consoleapplication1.cpp` to `ConsoleApplication1.cpp` (same letters, different case: upper/lowercase)? – VonC Feb 16 '22 at 16:38
  • No, it was already like that. – Computerized Free Will Feb 21 '22 at 07:27