Flutter: Pushing to GitHub from Visual Studio Code - flutter

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.

Related

Why I am not able to commit any repository in github?

I have many private repositories on my GitHub. Until yesterday I was able to commit to any repository on my GitHub. But today, I am trying to change the readme.md file in my repository, I am not able to see the preview and also not able to commit as the commit button is disabled.
Actually, later I saw that I am unable to commit any file in chrome browser only , but I can commit any file in other browser (Microsoft Edge) . And also, I am able to commit from my IDE (MS Visual Studio) . So, My question is that , why I am unable to commit from Chrome only.
I found solution for this problem:
Problem is occurring due to I Added extension in chrome i.e. ad blocker extension.
So, I removed that extension and problem is solved.
Make sure you have modified/updated any contents in the README.md file. If there is no changes in the file, "Commit Changes" but will be disabled.
I had the same problem until I deactivated/trusted Ghostery for uniquely github.com
Image shows active Ghostery:
I had the same issue. I found by adding the file name you are going to create in the url can solve the issue.
yourusername/new-file-name.html. (in main)

VS code doesn't highlight changed/added lines after moving the repo's folder

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.

Why .has .vscode folder been generated in my GitHub repo?

So, I started my Flutter project with VScode but later I completed the whole project from Android Studio and have now pushed it from Android Studio into my Github repo. In my GitHub repo, the .vscode folder (refer to the snapshot added) has been generated. Is this something I should be worried about and try removing it? I'm a newbie at Flutter and so kind of too meticulous about my codes. (^-^;)
No that's normal and automatically generated by vsCode
If it bothers you can simply ignore it using .gitignore in your project folder.

VSCode displaying freshly cloned files as modified with gutter indicators

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.

How do I use .gitignore in visual studio code?

So I know this might sound like a noob question but I'm rather inexperienced with GitHub. I want to add a gitignore file to my repository, but I am unable to do so and I don't know how. I want to make sure a file is gitignored My visual studio code is connected with my repository. So I am able to push and pull via visual code.
Greetings,
Parsa & Liyam
You may go to File > New File at the root of your git repository (same directory as where your .git hidden folder is in). Then add all the directories/file that you want to be ignored into that new file and save it as .gitignore. (You can save as a plaintext file and just name it .gitignore within VS Code.
Vscode 1.46 is adding some automated help in generating a .gitignore file when you publish to github. From v1.46 release notes:
Publish to Github: Generate .gitignore
It's now possible to generate a .gitignore file when publishing a
workspace to GitHub. When publishing a workspace to GitHub, you are
prompted to select which files to include in the repository.
You can press Ctrl+Shift+P on your Visual Studio Code and then search for gitignore. Click the add gitignore option then you are good to go.