First of all, create a Github account and project in Github. Go to the root folder and follow steps.
The most important thing we forgot here is ignoring the file. Every time we run Gradle or build it creates new files that are changeable from build to build and pc to pc. We do not want all the files from Android Studio to be added to Git. Files like generated code, binary files (executables) should not be added to Git (version control). So please use .gitignore file while uploading projects to Github. It also reduces the size of the project uploaded to the server.
git init
Create .gitignore txt file in root folder. Place these content in the file. (this step not required if the file is auto-generated)
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.idea
.DS_Store
/build
/captures
.externalNativeBuild
git add .
git remote add origin https://github.com/username/project.git
git commit - m "My First Commit"
git push -u origin master
Note : As per suggestion from different developers, they always suggest to use git from the command line. It is up to you.