This works whether or not you are using GitHub.
- Get the free GitHub for Unity package on the Asset Store. Despite the name, it works for Git as well.
- In Unity, import GitHub for Unity into your project.
- Open Window, GitHub.
- In the GitHub window, click Initialize.
- If nothing happens, try to close and restart Unity.
- Add https://raw.githubusercontent.com/github/gitignore/main/Unity.gitignore to your main folder. This will make git ignore all generated files such as build files or cached files.
- Select the files you want to commit, enter a title to your commit under "Commit summary". Entering a description is optional.
- Click "Commit to [master]".