如何开始将Git与Android Studio集成?

时间:2017-03-23 23:22:19

标签: android git android-studio intellij-idea

我已经在我的LAN上设置了一个Git服务器(适用于Mac的Simple Git Server)。我在局域网上使用其他机器进行Android Studio开发。现在怎么办?在Android Studio的VCS菜单上,"集成项目......"灰了。

如果我理解,我必须首先在工作站上创建一个本地存储库,然后以某种方式将我的项目文件放入其中并将其复制到服务器。无法弄清楚如何做到这两点。如果您已经设置并填充了远程存储库,它似乎可用,但我无法解决问题。

另外:是否建议为每个项目都有一个单独的存储库?

1 个答案:

答案 0 :(得分:2)

如果您已经在线设置了git存储库。首先,在要提交给git的目录中执行git init,然后需要通过对所有文件执行git add .或针对特定文件git add <your file>提交要添加的文件文件。之后,您需要通过git commit -m "your message here "提交文件,然后执行:

git remote add origin <remote repository URL> //get this from git assuming your have already set up the git repo
# Sets the new remote
git remote -v
# Verifies the new remote URL
Push the changes in your local repository to GitHub.

git push -u origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin

所有这些信息都来自这里的git文档: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/

是的,通常您希望为每个项目都有一个单独的存储库。有例外,但就个人而言,我还没有找到合适的。