Home > Software design >  Question about Visual Studio 2022 Community and Git
Question about Visual Studio 2022 Community and Git

Time:04-17

I have a quick question about Visual Studio 2022 Community and Git. So I am totally new to Git and I have not used it before. I don't have a Github account either and I don't plan on making one as of this moment.

I want to use Git as my version control since it comes with Visual Studio 2022 Community. However, I don't want commits of my code to be uploaded to the Github website. I want to keep all my code and all my commits on my computer, locally.

I see that I can create a Git repository locally in Visual Studio like this:

Picture of using Git in Visual Studio

As a test, I created a Git repository according to the image above, but when I try to commit my change, Visual Studio 2022 prevents me from committing my change unless I enter my username and e-mail address. Why would Git require that I enter an e-mail address, if all the commits are done locally on my computer?

So my question is, if I create a Git repository locally on computer according to the image above, will my code or commits be uploaded to the internet? I don't want my code or commits to be uploaded to the internet, I want to keep all my code and commits on my own computer, privately. The fact that I have to enter an e-mail address to make the commit locally on my computer is all the more confusing, since it should just be a local repository on my computer (sorry, my question may appear to be obvious to seasoned users of Git, but I am totally new to Git and the e-mail requirement makes it seem like my code & commits may be uploaded to the internet, so I am just double checking).

CodePudding user response:

When you create a commit, Git embeds two pieces of information to identify you as the author of the commits. Those are your personal name (that is, a name other humans call you and not a username) and your email. Git requires some entry in those fields. Usually, those are set with the user.name and user.email options in Git, but can be set other ways as well.

Even if you provide that information, that doesn't mean that your data will be pushed elsewhere. You can continue to use Git locally and not upload your code anywhere, but you do need to provide a name and email for Git to work.

This is because in the original Git workflow, the commits you make are formatted as patches and sent around to other people, and your personal name and email are required for that to work. As mentioned, you don't have to adopt that flow, but the data remains part of a commit.

  • Related