Don't allow VSCode to auto fetch from repos

Recently I had a very annoying experience using VSCode. I use git to track changes of my work, and I push important changes to my GitHub repo.

During the past 1 month I was hacking a small side project during my free time. Since I’m the only one working on the project I’m the only one who is pushing to the repo.

Whenever I was pushing commits to my GitHub repo, VS code is showing this popup, with this message. “would you like code to periodically run git fetch?

Image stolen from Twitter

At the beginning I ignored this message and clicked ask me later. But since it is nagging me during every push to GitHub, since I’m the only one pushing commits to the repo, and thinking that it will warn me when there is conflict between versions, or code. I decided to click yes, allowing VsCode to run git fetch “periodically”.

I’m using GraphQL for the project, and GraphQL is something that I learned this year (2021). And GraphQL doesn’t have a type to upload a file, I had to dig though the internet for a way and some npm packages to find a suitable package to handle file uploads.

I finally found out a package, and it took me a whole day to cook a way to work it together with Amazon AWS package to upload a file successfully to an s3 bucket. It was frustrating and took me a whole day, and staying up till around 2am to figure everything and make it work.

I’m not going in to detail, but first the file was not uploading, and second the uploaded file was corrupted, and had to fix some other bugs before it finally worked.

So I was happy. On this project I had this habit of committing and pushing everything to GitHub before I went to bed. And since it was 2am in the morning, I didn’t push the commits to GitHub and instead went to bed.

The next day I started again on the project, did some changes, and when I was testing for the changes, the file uploading function did not work, and was giving an error, which I’m sure I fixed and it worked the other night.

I thought maybe it was the changes that I just made during the morning that was causing the error, even though it had nothing to do with file uploading, I was adding some features to my GraphQL API.

I quickly undid some of my changes, ran the program again, still getting the same error, undid some more, still the same error, undid all the work that I did in the morning, still the same error.

I was dead frustrated, it took me a whole day to figure everything yesterday, and now again I had to work on a file uploading function? Does this has to do with the package I just selected to handle file uploading in GraphQL?

After checking my GraphQL API, and nothing seemed to work, I decided to take a look at the file uploading module I just created yesterday. And I was surprised to see what I just found.

Some of the important changes I just did to the file uploading module has be reverted to a previously pushed commit, because I was yet to commit them and push it to GitHub.

Then I fixed everything again and changed everything to as they were when everything was working fine and finally committed and pushed it to my repo.

The next thing I did was quickly find a way to turn off the auto fetch, because I was afraid that my project will be taken back a whole day, and all other important changes I just made during the day will be lost (like I said earlier for this project, I had the habit of committing and pushing at the end of the day)

Turn off auto fetch on vs code

Turn off auto fetch on VSCode

So I went to preferences, searched fetch, and it will show the auto fetch option. I opened the settings.json and set auto fetch to false. Now that it won’t fetch commits from the repo and changing my code without my notice.

I’m not an advanced user of Git, I use to track changes, and push them to GitHub, and maybe my idea of fetch was wrong, which I thought it would warn me when there is a difference or conflict in the code.

While according to Justin even though it did not affect my local branch, here it did affected my local branch, and if anyone is using auto fetch feature on GitHub please let me know in the comments so I can learn and improve my VSCode skills.

I guess until I figure the importance of this feature, it is better to keep the auto fetch as false and fetch manually when it is only required.