I would like to commit changes which I did in my AS project. But I see that changeslist contains release folder:
It means that I will commit workable apk file and some config files which were generated during building installer. I can also untick these files but when I will try to make commit at the next time I will see these files again. Maybe I can remove these files totally from my changes list and prevent its appearing at all next times. I think it happens because I tried some commands at the terminal and one command can add these files, I think it was:
git commit --am
So, how I can solve this problem without damaging all project?
UPDATE:
Can I solve my problem with the command:
git rm --app-release.apk ?
First Things first:
You can add a .gitignore file to your repository, via terminal, by the commands below:
In Terminal, navigate to the location of your Git repository.
Enter touch .gitignore to create a .gitignore file.
Second, you should pay attention that, If you already have a file checked in and you want to ignore it, Git will not ignore the file if you add a rule later. In those cases, you must untrack the file first, by running the following command in your terminal:
$ git rm --cached FILENAME
for more information on this follow https://help.github.com/en/articles/ignoring-files
First add the file/folder to your .gitignore file (In your case, the app-level one and not the project-level one)
Go to the Terminal in Android Studio and type in these commands:
git rm -r the-directory-to-remove In which case your the-directory-to-remove is the release folder.
The above command will remove the specified directory from git.
git commit -m "Delete release folder"
The above command commits the changes, you can change "Delete release folder" to whatever you like.
git push origin <your-git-branch>
The above command pushes the changes to Github (or BitBucket).
Now, if you want to delete the file from Github/BitBucket ONLY but not from the entire git filesystem, run git rm -r --cached myFolder instead of the first command.
you need to add those files in your ignored files under version control area in your android studio. For navigation go to
Open File -> Settings -> Version Control -> Ignored Files.
Add files those you don't want to commit or include. Another way of doing it like the other answer suggested to do it with .gradle tools.
I'd recommend using https://www.gitignore.io/ for generating .gitignore file for your android project and put it in your root folder of the project.
https://www.gitignore.io/api/android gives a headstart for your android project(Modify this according to your requirement. But for most cases this should be out-of-the-box solution).
Also, to add to the point. This is expected behaviour of git and not related anyway to android studio/android.
Step 1: Remove file's from staging area using below command
git reset HEAD file
check this
similar post
Step 2: add release folder and other generated file's to your .gitignore
Ref:
If you have a gitignore file then add this line
# Built application files
*.apk
*.ap_
*.aab
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# IntelliJ
*.iml
.idea/workspace.xml
.idea/tasks.xml
.idea/gradle.xml
.idea/assetWizardSettings.xml
.idea/dictionaries
.idea/libraries
.idea/caches
# Keystore files
# Uncomment the following lines if you do not want to check your keystore
files in.
#*.jks
#*.keystore
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
# Google Services (e.g. APIs or Firebase)
google-services.json
# Freeline
freeline.py
freeline/
freeline_project_description.json
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md
or create a .gitignore file in your root folder of project
Related
I am new to React Native and I work with a colleague on a new app. I created a new react native project which has generated a .gitgnore file as well. In it all the .gradle files (and thus the build.gradle file inside /android/ folder) are ignored.
When I pushed the project to Github and my colleague pulled, he npm install to download the node_modules (which are also excluded <- I have read the rational behind this) and then he run react-native run-android. This failed. We realised that if he creates the build.gradle file inside /android/ and copy-paste the contents of my build.gradle which I have locally (as is ignored by git) everything runs smoothly.
My main questions are:
1) Should the build.gradle file be ignored as react native does by default?
2) If yes, how are teams supposed to work on a react native project if they somehow need to get the build.gradle contents to run the project on their side?
3) What happens if my disk drive fails? I can pull everything from git but I will not have the build.gradle. Should I right it from scratch?
The contents of the .gitignore file:
# OSX
#
.DS_Store
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace
# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
# node.js
#
node_modules/
npm-debug.log
yarn-error.log
# BUCK
buck-out/
\.buckd/
*.keystore
# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/
*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
# Bundle artifact
*.jsbundle
It is .gradle file in .gitignore and not the *.gradle or build,gradle.
So the answer to your questions is build.gradle is not ignored and should not have to be ignored.
The android related things included in .gitignore are:
build/
.idea
.gradle
local.properties
*.iml
android/gradle.properties
For standard, you can refer to this below two sample .gitignore file.(you can replace your .gitignore contents with the below link contents and can check.)
enter link description here
https://github.com/facebook/react-native/blob/master/.gitignore
https://github.com/facebook/react-native/blob/master/local-cli/templates/HelloWorld/_gitignore
You have to check in your build.gradle files, only the .gradle directory should be ignored.
I'm new to Git and Android development and I could not find an answer to this question.
When I build a project in Android Studio a lot of files are created in the folder app/build.
I guess I don't need that files, but before ignoring them in the .gitignore, I would like to be sure to not mess my repo since from the first commit :D
I checked this question, but I cannot see in the example .gitignore the folder app/build.
Should I add it to my .gitignore?
P.S. I'm using Android Studio 2.2.3, if relevant
I guess I don't need that files, but before ignoring them in the .gitignore I would like to be sure to not mess my repo since from the first commit :D
You don't need build files in your repo.
Usually .gitignore file contains /build.
I checked this question but I cannot see in the example .gitignore the folder app/build.
You can place another one .gitignore file to app directory, the content of this file also contains /build.
/project
.gitignore
/app
.gitignore
If I copy/past the example .gitignore (which contains build/ ) in the app/ folder, build files are not ignored.
That would be because those files are already tracked.
Try:
cd app
git rm --cached -r build/
git add .
git commit -m "record build content deletion"
git push
Then app/build will be ignored.
Have a look at gitignore.io for generating gitignore files
I use Android studio almost all day - everyday.
I'm aware that it's a build of IntelliJ.
I also use Git, and I switch between branches hourly.
I was wondering, cause I cannot find a solution searching around:
Is is possible to save open tabs so that when I switch branches I don't lose all my currently open tabs for files that don't exist, plus it would be super nice to see that work-space-view again. when switching to the concurrent branch.
For your information:
.idea and *.iml folder contains all the tab and work space related information of Android Studio Project.
Why it is not stored in git branches:
Typically when we create a .gitignore file for Android Studio project we include .idea folder and *.iml in ignore list. That's why switching branches doesn't keeps the changed preferences.
What to do:
If you want to track this information for git branches then simply remove this two files from .gitignore list. You can add an extra # before .idea and *.iml
# Built application files
*.apk
*.ap_
# Files for the Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
# Gradle files
.gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
#idea/studio
.idea
*.iml
.DS_Store
captures
I created a test project inside of Android Studio and then I used following: VCS -> Enable Version Control Integration -> Git -> Ok, then via Project -> Android -> app, I selected Git -> Add & Commit Directory.
And on another computer with Android Studio installed, I did following: Check out project from Version Control -> Git -> (I modified URL) Git Repository URL -> Clone, Android Studio asked me a lot of questions...
yet, project isn't same as on my original computer...
What am I doing wrong?
* UPDATE *
[alexus#wcmisdlin02 Test]$ git status | grep -A11 Untracked
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
# .idea/
# Test.iml
# build.gradle
# gradle.properties
# gradle/
# gradlew
# gradlew.bat
# settings.gradle
[alexus#wcmisdlin02 Test]$ cat .gitignore
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
[alexus#wcmisdlin02 Test]$
The *.gradle files are required in order to build the app project successfully. In other words, these files should be included in the VCS.
build.gradle contains part of manifest and list of library dependencies.
settings.gradle contains depended projects. Some projects provide entire source code.
The simplest choice is to include all files in the project folder to VCS except files under .idea folder. The .idea folder has IDE(Android Studio) specific files. For reference, the name idea is come from original program IntellJ IDEA.
If you do not want to give permission to change apk file by others, it is better to exclude keystore file.
Upon your editted question, I appended descriptions accordingly as below.
.gradle : .gradle folder has gradle execution files.
/local.properties : the keystore file location or computer-depended information like JDK path are described in here.
/.idea/workspace.xml : it has your IDE panel location or trivial IDE settings.
/.idea/libraries : it is automatically created/regenerated when you clean and build the project. The jar files of dependencies listed in build.gradle are downloaded and stored in here.
.DS_Store : Macintosh OSX specific folder description file.
/build : build results.
/captures : This is not a common thing. It might be your project specific folder.
I'm trying to checkout a new branch in Eclipse using Egit but I keep getting the same message:
I tried dealing with this in any way possible. Selecting "Commit"or "Stash" only tells me that there are no changes to be stored. Selecting "Reset" only makes the error reappear after a few seconds. Other than this I pulled, cleaned and re-cloned the project a few times. I also created the following .gitignore file:
*target*
*.jar
*.war
*.ear
*.class
# eclipse specific git ignore
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
Still no luck. I really don't know where the problem is.
Make sure bin isn't already versioned:
git rm --cached -r bin
Add bin to the .gitignore
bin/
(no need for /**)
And finally, try again to checkout the other branch.