如何使用.gitignore文件将现有的Android项目推送到GitHub仓库?

时间:2022-08-04 15:32:30

I am developing my Android app on Eclipse. It works fine and run properly. But, I want to migrate to Android-Studio. Here is what I am doing:

我正在Eclipse上开发我的Android应用程序。它工作正常,运行正常。但是,我想迁移到Android-Studio。这是我在做的事情:

  1. Create a repo in GitHub with .gitignore, a README.md and LICENSE files
  2. 使用.gitignore,README.md和LICENSE文件在GitHub中创建一个repo

  3. From within my project folder run the following commands:

    从我的项目文件夹中运行以下命令:

    • git init
    • git add .
    • git add。

    • git pull git-url master
    • git pull git-url master

    • git init (again)
    • git init(再次)

    • git add . (again)
    • git add。 (再次)

    • git commit -m "First commit"
    • git commit -m“第一次提交”

    • git remote add origin git-url
    • git remote add origin git-url

    • git push -u origin master
    • git push -u origin master

  4. From Android-Studio, I checkout the project from Git

    从Android-Studio,我从Git结账项目

  5. Run the app from Android-Studio (after alot of configrations)
  6. 从Android-Studio运行应用程序(经过大量配置后)


My concern is that ALL my project files and folders are pushed to the remote repo at GitHub, including for example: bin\ and .settings\ folders. Meanwhile, I only need to push the important and platform independenet files because I work in both windows/mac systems and in differnet locations (hence, this is the reason behind using version-control).

我担心的是我的所有项目文件和文件夹都被推送到GitHub上的远程仓库,包括例如:bin \和.settings \ folders。同时,我只需要推送重要的和平台的独立网文件,因为我在windows / mac系统和不同的位置工作(因此,这是使用版本控制的原因)。

My questions are:

我的问题是:

  1. How to pull the files on GitHub first, and then use .gitignore to push the "important and platform independenet" files from my project folder into GiHub
  2. 如何首先在GitHub上提取文件,然后使用.gitignore将“重要和平*立网”文件从我的项目文件夹推送到GiHub

  3. What is the recommended method to export a project from Eclipse to Android-Studio while using GitHub ?! should I:
    • checkout the project from Git (as I am doing now) ?
    • 从Git结账项目(我现在正在做)?

    • use Eclipse Export Tool ?
    • 使用Eclipse Export Tool?

    • or clone the project first into a directoty and then loaded into Android-Studio as an existing project ?
    • 或者首先将项目克隆到directoty,然后作为现有项目加载到Android-Studio中?

  4. 使用GitHub时,将项目从Eclipse导出到Android-Studio的推荐方法是什么?我应该:从Git结账项目(我现在正在做)?使用Eclipse Export Tool?或者首先将项目克隆到directoty,然后作为现有项目加载到Android-Studio中?

1 个解决方案

#1


0  

  • You can pull your files by git pull origin master command from GitHub.
  • 您可以从GitHub通过git pull origin master命令提取文件。

  • Add the name of the directory/file in .gitignore file you don't want to push. see more
  • 在您不想推送的.gitignore文件中添加目录/文件的名称。看更多

  • You can clone the project first into a directory then load it in Android-Studio.
  • 您可以先将项目克隆到目录中,然后将其加载到Android-Studio中。

#1


0  

  • You can pull your files by git pull origin master command from GitHub.
  • 您可以从GitHub通过git pull origin master命令提取文件。

  • Add the name of the directory/file in .gitignore file you don't want to push. see more
  • 在您不想推送的.gitignore文件中添加目录/文件的名称。看更多

  • You can clone the project first into a directory then load it in Android-Studio.
  • 您可以先将项目克隆到目录中,然后将其加载到Android-Studio中。