Using Git in Android Studio

Information is based on this post:

http://wii.logdown.com/posts/2013/11/15/android-studio-git-tutorial

I added more steps based on my experience.

Assuming you already have a Git account and have downloaded basic Git tools such as Git Bash.

For New Projects

Step 1

Go to your account on github.com.  Create a new repository.  Let’s call it NewProj.  DO NOT initialize the repository with a readme file.

Step 2

Install Git for Windows.

Step 3

Go to Android Studio.  Open the project.  Go to File > Settings > Version Control > Git.  Test login.  It must be successful.

Step 4

Enable version control in your project.

VCS > Enable Version Control Integration > select “Git”

Step 5

Add git remote locally.

Start Git Bash.  Go to your project directory.  Issue the following command:

git remote add origin https://github.com/(your user name)/NewProj

Step 6

Go back to Android Studio.  Select <project/file> > VCS > Git > Add to VCS.  This does a Git Add

Step 7

Commit chagnes:  VCS > Commit Changes

Step 8

Write down commit message, then choose commit.  Push repository to github by selecting VCS>Git>Push

 

Possible error messages:

Push failed: fatal: Authentication failed for ‘https://github.com/(user name)/NewProj/’ – your password for Github is incorrect.  Go back to Step 3 to test your connection

Push failed: fatal: repository ‘https://github.com/(user name)/NewProj/’ not found – you didn’t create a new repository on Github.  Go back to Step 1.