over 3 years ago

Android Studio has git plugin, which can make you have a well version control on your project.

In this part, I will show you how to create a new repository at Android Studio on Windows OS.


Prepare :

At the first, you should install Git for Windows.

And then, Setting git tools path for Android Studio.

File > Settings > Version Control > Git

You can click Test button to check function. Such as figure below.

git tool test.PNG



Step 1 : Enable Version Control Integration(git init)

VCS > Enable Version Control Integration > select "Git"

And then, you will discovery that your project list changed color. Like figure.
git add.PNG

※ build folder & local.properties doesn't added.



Step 2 : Git Add Remote

In this step, Android Studio doesn't provide GUI to work, We should use Git for Windows tool.

Go find Git Bash in git folder.

  1. Git Bash > Go to Project folder

  2. Git Bash > key in add remote command
    Ex: git remote add origin git@192.168.0.1:user/android-studio-git.git

command.PNG



Step 3 : Add to VCS(git add)

Select <project/file> > VCS > Git > Add to VCS
add.png




Step 4 : Commit Changes(git commit)

VCS > Commit Changes...

Write down commit message, then choose commit.

If you select Commit and Push..., the git push window will pop up.

commit.png



Step 5 : Git Push(git commit)

VCS > Git > Push

If your repository is empty, you must select Push current branch to alternative branch

git push.png

If push completely, you will see Push Secessfully at the bottom of Android Studio.




This tutorial's git server is private server, not GitHub.

Pushing to GitHub is easier, I will write down later.

Now, enjoy version control at Android Studio with Git.



PS.

I perfer to install tortoise git, addtionally.

Because icons, open on windows, would be more pretty.

Moreover, you can use GUI to do Step 2.

← Android JNI Using Log Android Studio Git Tutorial (Part 2) →
 
comments powered by Disqus