I recently had some issues with my local github repository, so I deleted the entire folder (including all the .git files) and cloned a new fresh copy. However, when I open the files in VScode, the code does not match what is on the online github repository. Instead the actual updated code I want is displayed in gutter indicators. The code that isn't in the gutter indicators is an old version of the code. However, if I open the files in another editor not linked to github, it displays the file correctly. I suspect it might be related to a local commit or stash, but I am fairly new to github so I am not sure what to do.
Or possibly a vscode issue?
I tried git revert and hard reset, but so far nothing has fixed it. Also, if I try to save I get a VSCode error: "Failed to save 'filename': The content of the file is newer. Please compare your version with the file contents."
This is an Angular project by the way (not sure if that matters)
EDIT I fixed it. I just completely removed and reinstalled all the add-ons on VSCode. So I guess it wasn't a git issue, just some kind of bug with VS Code
EDIT2 Turns out it didn't fix all of it, because I am still getting some gutter indicators, even though it removed some of them.
EDIT3 I did git rm --cached . -r -f in the local repository and then completely recloned it again. Seemed to remove all the gutter indicators so far...
Try and:
clone a fresh copy in a new folder (separate from your old one)
Add that new folder to your VSCode workspace with "Add Folder to workspace"
open files from the ones displayed in Explorer tab.
Those files should be the updated ones, not the old ones.
Related
Screenshot of greyed out lib folder and dart files
Hi there, has anyone else encountered the issues where the lib file is greyed out in visual studio code, and all other dart files inside are greyed out as well?
It seems to cause an issue when pushing the files to GitHub with the GitHub desktop app. I have tried looking at the .gitignore file, but I have not been able to solve the issue.
Anyone managed to solve this issue?
I have tried changing the name of the file from 'lib' to 'library', and the folder was no longer greyed out. However, doing so caused the code to crash and I have changed it back to 'lib' for the time being.
It is not an error, it will be automatically grayed out when you add and commit the files in GitHub.
There are some green indicators that are indicating that either you have add those files in your local git but didn't commit yet, or you have created new files that aren't tracking by Git. When you add those files to your Git repository and commit it, all the files will be grayed out.
I decided to reorganize my folder structure inside the folder with my repos. After moving my repo's folder to another place, VS code stopped highlighting changed/added lines as well as stopped showing places where lines were removed. You can see the way it does it on the picture below.
When I try using source control in the folder I see the following message:
The folder currently open doesn't have a git repository. You can initialize a repository which will enable source control features powered by git.
Although, command-line git does understand that this is my repo and does track the changes and sees the entire commit history.
I tried googling but found nothing. Please help.
I decided to commit and push the changes, remove the repo, and clone it again. But it didn't help. I was still seeing the message in the source control page.
Interestingly, restarting my computer solved the issue.
How do I get rid of these 'changes' on Visual Studio Code? There are over thousands of files and I was not aware of these changes since I installed vs code on my MacBook. I tried git reset --hard on the terminal, but nothing has happened. I also do not recall having these files on my laptop and VS Code cannot even open these files. VS Code also failed to notify me of these 'changes'. Whenever I try to delete all the files, it says git: fatal: you are on a branch yet to be born
See screenshot below:
All of these "changes" are most likely do to you initializing git in a folder with lots of settings and configuration folders. For example, in the screenshot, I can see that most of the "changes" are from .eclipse folder, a folder Eclipse uses to store configurations. You usually cannot see these folders, because they are "hidden" folders.
Solution 1
The first solution is to add a .gitignore file, to ignore all of those unnecessary folders. To do this, just add a file named .gitignore to the current folder. Then in that file, put a list of all of the folders to be ignored. For example(Go through the list of "changes" and add more folders):
/.eclipse
Solution 2
The other solution to seeing these changes is just deleting the .git folder. You can't see this folder by default, because it is a hidden folder. To see this, you have to go to Finder, and press Command + Shift + .. After you see the .git folder, you can just delete it. The changes should now go away.
I've created a new project on OpenShift and cloned it locally. But now i'm having problems adding new files and folders to git index. Right click on the new folder (with files and subfolders) in project explorer and choosing Team -> Add to Index, changes nothing. And if i try to commit, Eclipse says that there aren't any changes... (If i only update existing files, everything seems to be fine).
What could be the problem?
Make sure that you have the "Git Staging" view open, and right click on the file in your Unstaged Changes and Select "Add to Index", also make sure that the file is not empty, it did not show up as a staged file until after i added some content to it, even after I had added the file. (Can't add empty files or directories to git with EGit maybe?)
this sounds like EGit missing new files. I'd love to know a bit more about your setup:
Where did you clone to, where is your Eclipse workspace?
To make sure your git setup is right I suggest that you do the same with the git command line:
cd [git-repo]
git status
Git status should list the new files and tell us that they're not added yet. If they get listed, then we know that your git is set up right and we can get back to Eclipse to try to figure out what's wrong with it.
Found out what the problem was (kind of stupid though). The folder that contained new content was listed in .gitignore ... but that file isn't accessible through eclipse, i had to look it up on filesystem. I also don't have a clue, how that line came to .gitignore...
Well, that's it...
Yesterday I wanted to start using Eclipse eGIT on an existing project following the instructions on http://www.vogella.com/articles/EGit/article.html
This tutorial suggests to have the git repository outside of the workspace, and I followed this suggestion.
After the step "5.5. Using the Git Staging view for the initial commit" I committed my initial commit. Then I continued editing one of my source files that was still open. But when I tried to save my changes, Eclipse complained that the source file was no longer there.
Then I checked both my workspace and git folder, and the project files were only in git. This is mentioned nowhere in the tutorial. Is this normal behavior?
Even more surprising: In order to continue working normally with my already open files, I copied the project subfolder from .git back to the workspace folder. And now everything seems to be fine. My changes are reflected in workspace folder as well as in "Unstaged Changes" in the Git Staging view and in git folder.
Is this expected behavior?
I found out that the files really get moved. I needed to close all the open project files and then open them from package explorer again (which will open the files from git repository).