Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use git with Flutter and Android Studio?

I created a Flutter project in Android Studio and I uploaded it or pushed it or whatever to a git repository bucket something. Then when I try to 'Check out project from Version Control' in Android Studio on another computer, I get the following:

Would you like to create an Android Studio project for the sources you have checked out to... (folder where the project is)?

Why is it asking me this? I want to have the same project I had on the first computer downloaded to the second computer. I don't want to make a new project, I want to check out the project and for it to just work.

Given that so many programmers are using git rather than just zipping the project and unzipping it on another computer, I assume it's not supposed to be this useless and that I'm doing something wrong. My best guess is that not everything that's needed is on git due to the .gitignore file so here are its contents:

# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Visual Studio Code related
.vscode/

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
/build/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
like image 509
TimSim Avatar asked Jul 01 '19 09:07

TimSim


2 Answers

danypata tell you the one to use git.

I am assuming you have installed the git on your device.

Here is the second if you already worked on Android Project and wants to add the git in it.

Step 1: Just open the terminal in android studio.

Step 2: execute 'git init'

Step 3: git remote add origin "HTTP URL OF THE REPOSITORY"

then execute normal commands

Step 4: git add .

Step 5: git commit -m"Message"

Step 6: git push origin master

like image 86
Sunny Avatar answered Sep 16 '22 13:09

Sunny


To support other new devs (and suggested by OP) I will post my comment as an answer.

The easiest way to import a new project from a git repository (or any repository) is to first clone the repo from git, svn or whatever. Then open it from Android Studio, first time you open the project, Android Studio will detect the VCS (git, mercurial, svn etc) and will ask you if you want to manage the repo using Android Studio. If you "allow" it, it will track the changes for you and it will enable a cool IDE for repo operations (commit, push, pull, etc).

like image 37
danypata Avatar answered Sep 19 '22 13:09

danypata