- Next, open Android Studio and create a new project. Call your new application TestAndroidProject.
- Check Phone and Tablet checkbox and select Minimum SDK from the dropdown. Now click Next.
- On the Add an activity to Mobile screen select Blank Activity and click Next.
- In the next screen, leave the default activity name of MainActivity and click Finish.
- Your new project will open in Android Studio. On the top menu, select VCS > Import into Version Control > Create Git Repository…
- On the next screen, set the path to main directory as shown below and click OK.
- Now use Windows Explorer and navigate to the root of your projects folder. Right click and select Git Bash (If you do not see this option, then first install Git for Windows).
- When the Git bash screen appears, type the following command and press enter :
git remote add origin https://github.com/[Username]/[Project Name].git
An example of a Git repository URL is:
https://github.com/ShaikhSikander/TestAndroidProject.git
https://github.com/ShaikhSikander/TestAndroidProject.git
- Next, jump back into Android Studio. On the top menu, select VCS > Git > Add. This will add all your project files to your Git repository.
- Now go on the top menu again and select VCS > Git > Commit Directory.
- In the next screen, type a Commit Message and select Commit.
- If a Code Analysis warning appears, click Commit. (Unless it’s a real project, in which case review and fix the issue before committing!)
- Now, go on the top menu again and select Git > Repository > Push.
- Check the box Push current branch to alternative branch and leave the branch name as master. Then select push.
- Now enter your GitHub Login (email address) and Password. Then click OK.
- If it’s all good, you will see this message.
- Now your code is pushed to your GitHub repository.
I hope you found this post helpful. Please let me know in the comment below.
Thank You..!!
0 Comments