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.
Related
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
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 have an Android library and for some reason, the files and folders I have specified in my .gitignore are not being ignored.
I have tried modifying my .gitignore and also following these steps, but this doesn't change anything.
Here is my top-level .gitignore (which can also be found on the GitHub repo):
# Gradle files
.gradle/
build/
*/build/
# Local configuration file (sdk path, etc)
local.properties
# IntelliJ
*.iml
/.idea
The module with the build folder that isn't being ignored has the following .gitignore:
/build/
I'm not sure why the build directory isn't being ignored, as it is being ignored in my sample app module, and in the top-level directory.
Also, I did commit changes to some files in the build directory when I updated versions of my library, if that's important.
This answer on Stack Overflow helped me solve my issue.
Here is part of that answer:
First commit any outstanding code changes, and then, run this command:
git rm -r --cached .
This removes any changed files from the index(staging area), then just run:
git add .
Commit it:
git commit -m ".gitignore is now working"
You must remove the first / in your lower level gitignore before build, it will work then.
Also, in top level, you only need this: build/ and then no lower level gitignore will be needed.
Add .gitignore file in your project, and set below lines:
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/build
/captures
.externalNativeBuild
.idea
In my case the .gitignore file was placed inside app directory instead of being in root of project directory.
I figured this out by:
Open Project View in Android Studio
Right-click on build folder
Select Git
Add to .gitignore
Question partially related with gitignore file.
Now when you create an Android project, Android Studio creates .gitignore with your project.
BUT it does not help, these files would be ignored if your code is already in git repository and ignored files ARE NOT already pushed.
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
Now i create a project, Android Studio creates tons of other files including , .idea .IML and so on and i have no idea how can i clean these irrelevant files and folder so i can push clean code to he repository.
Should i do this manually
if ignored files are already in your repository then you should cut them to a new folder outside repository (ex. desktop) then commit deleted files and then turn them back to repository ! this time they will not been tracked by git because they are in your .gitignore file
You can use git rm to untrack files without removing them if you have access to a terminal with git.
I m collaborating with another developer over git. Our setup environments are different. To avoid adding the correct sdk and other libraries I decided to include this line in .gitignore
#eclipse
project.properties
but in the initial commits my project.properties file was pushed onto the repository. I thought updating the .gitignore file would take care of this problem on the other developers machine. But every time he pull the repository he has to update the project with the path of his sdk and library to be able to run the code.
If you want to ignore a file within your git repository that was already tracked by the system, you have to delete the file from the repository cache. After deleting the file, you can add the ignore rule to your .gitignore file and it will be ignored by the repository.
First: Delete the file from the repository cache
git rm --cached path/file
Second: Add the ignore rule to your .gitignore file
path/filename
Third: Commit the updated .gitignore file
git add file
git commit -m "Updated .gitignore rule"
git push
found here:
http://www.wegtam.net/article/add-file-gitignore-was-already-tracked