Setting up mercurial repository with Android Studio, .gitignore file - android

I've just attempted to create a new mercurial repository using Android Studio (v2.3.2)
I went through the menu option VCS->Import into Version Control->Create Mercurial Repository
The 1st time I did this I was careless and accepted the default folder location for the repo which turned out to be the parent dir of my new project, thus overwriting an existing repo I had there (hopefully I can restore from backup)
The 2nd time I correctly specified the new project dir and I saw that an .hg dir was created in there as expected. Confusingly though, it also created a .gitignore file in the project dir as well.
Does mercurial attempt to read .gitignore files or is this a bug in Android Studio?
Running hg add -n seems to suggest it isn't reading the .gitignore file
I would have expected Android Studio to create an .hgignore file instead?
Is the expectation you have to either rename the .gitignore file to .hgignore and add the syntax: glob line at the top or are you supposed to manually create your own .hgignore file?
I assume it isn't a good idea to simply add all files?

Mercurial doesn't read a .gitignore file or treat it specially in any way.
However you can probably convert it by adding the syntax: glob directive at the top and renaming - as you suggest yourself

Related

Android Studio keeps adding additional files to GitHub

I'm using Android Studio 2.2.2, using the built in VCS tool. For some reason, Android Studio automatically adds a bunch of extra xml files and folders that I did not add nor edit.
More specifically, it's adding the following files when I don't want it to:
/_windows
IntelliLang.xml
debugger.xml
diff.xml
vcs.xml
web-browsers.xml
This makes making pull requests downright impossible as the master branch doesn't have these files, and none of my other group members seem to have this problem either.
Any help in removing / configuring Android Studio to stop this pesky bug?
--
edit: I am already using a gitignore file already. The weird thing is that my additional files are in the wrong folder too. Basically, my root folder, has a subfolder for my app. All the junk files are created in my root folder for some reason by Android Studio.
/root/
/_windows
IntelliLang.xml
debugger.xml
diff.xml
vcs.xml
web-browsers.xml
/my_android_app/
gitignore for my app
/files actually needed for my project
Turns out this feature is called "Settings Repository", and it's intended to save IDE settings automatically. I guess I might accidentally agree on some popup from IDEA which look like add files to the git repository, so this started working.
FIX: Open Preferences → Tools → Settings Repository → Delete. I also disabled Auto-Sync. Dunno where it's going to save if I delete everything, but I switch it off to be extra safe..
Use gitIgnore file.. i am currently using this .
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
.externalNativeBuild
/captures
check if the same works for you or not ..
if you want to know the details please check here
If the IDE you are using is adding files that it requires, but which you don't want to be included in your repository, then this is a good candidate for additions to your .gitingore file.
Are you currently using a .gitignore file?
More information can be found here:
https://git-scm.com/docs/gitignore
You basically add an entry for each file or folder you want to ignore, and as a result, git will no longer try to include these files in commits going forward.
There is a good resource here:
https://github.com/github/gitignore
For creating a default .gitignore file. You would pick the .gitignore template that closely matches the type of development that you are doing, and customize from there. For example, I always start with the default Visual Studio template.
Probably the best suggestion would be to use the template .gitignore file for Android Development which is located here:
https://github.com/github/gitignore/blob/master/Android.gitignore
NOTE: I would copy the contents of this linked file into this answer, however, these template .gitignore files are always changing, as new recommendations are being added. It is best to keep referring to the source file for the most up to date version.
It doesn't explicitly ignore the files that you have mentioned, but it could be that those files are created within a folder that is being ignored.

How to keep library files out of github in android?

How do I keep library files out of my github repo yet still have them work if someone downloads my code? I get about 600 "changes" each time I make a small change to my code! Also if it changes anything I am using github desktop (not through cmd). Thanks in advance!
you need to use git ignore to ignore your build folders from updating with git. git ignore helps you to make a blacklist of items you dont want to commit everytime.
you can see how to make a git ignore file in below:
How to create .gitignore file
I guess you see changes to the workspace files modified by Android Studio / IntelliJ in the .idea folder. These files are automatically re-generated if you remove them and should be private to each user, i.e. not uploaded to source control with git.
Step by step fix
Close Android Studio
Remove the .idea folder in your project root (or backup elsewhere for now)
in the .gitignore file in the root of your project, add a line containing just .idea to ignore the folder and its content when you use git
Commit changes to git which should be the removal of the .idea folder & the .gitignore change
Open Android Studio, re-import you project
.idea folder is now regenerated and private to each git user
Run git status to verify

Git ignores directory that is not in .gitignore, exclude or config file

I have a directory in my project that is being ignored but it is not in any of the places that I would expect ignored folders to be (.gitignore, exclude or config).
it is an Android Studio project that I build with gradle, my VCS is Git.
I'm using SourceTree & GitBash to manage the repo.
I've reset all .ignore files in my project to be empty, \info\exclude is empty and config doesn't have 'excludesfile' property.
folder being ignored is - 'myProj/app/src/debug/res/raw/'
have no idea how this folder got ignored in the first place.
there is a different relative folder 'myProj/app/src/debug/res/values' that is tracked by git.
Is there any other place I didn't look that set ignore files?
Is there any git command that can show where is this folder being set as ignored folder?
maybe a binary I overlooked that I can just delete?
currently running 'git status --ignored' show only 'myProj/app/src/debug/res/raw/' as ignored.
Use git check-ignore -v myProj/app/src/debug/res/raw/ to see where the ignore is. You may have to give it the name of a file in that directory instead of the directory itself.
Thanks guys for responding so quick,
I've eventually resolved the issue by just adding the folder using:
git add -f myProj/app/src/debug/res/raw/
then commit and push, this was suppose to be a meanwhile solution until real solution is found but did the trick, after doing that the folder started to be tracked.
Note that your rule may also exist in the .gitignore_global file (in your user folder). You may have accidentally added it by choosing "Global ignore list" in the "Add this ignore entry to" dropdown in SourceTree.
You usually don't want to add a folder name to your global ignore list
I know this question is 5 years old but it's the first one on Google results.
Another possibility besides the ones mentioned before is that the folder has been added as a submodule. E.g. in GitHub, the bottom folder is a submodule:
This happened to me recently while copying a whole git project into another. That is, my repo looked like this:
repo
|
|__ .gitignore
|__ .git/ #git folder for repo
|__ some_files.ext
|
|__ ignored_folder
|__ .git/ #git folder of the copied repo
|__ .gitignore
|__ some_other_files.ext
My specific solution was to:
Cut the whole ignored_folder outside of the repo.
Add&commit to delete the submodule in the repo
Delete the .git folder inside the moved ignored_folder.
Move the ignored_folder back in.
Add&commit.
However, I'm sure there are much better git-like solutions.

Git not showing 'assets' folder

I have a folder called 'assets' ( auto generated when creating a new android app using the wizard in netbeans ) but it does not show up in the git command line, nor does it get added to the repo even if I try to.
Any help?
Sounds like the directory is git-ignored. Check .gitignore at the root of your Git repo, and ~/.gitignore (your global ignore settings). Does assets show up in there? If so, do git add -f assets/ to force the add.
Git doesn't work with (empty) folders, only with files. If you need to commit a folder you need to check a file within, in order to force git to recreate that folder.
I suggest you to commit an empty file that begins with an underscore '.' like ".keep", this file will be ignored by android build process.
I hope that helps you

Mercurial creating extra files after cloning a repo

I am working on an Android App and the APK file is located in the out folder. I am also using Mercurial as version control system and cloned the repo, the clone was successful but Mercurial created two APK files one inside the bin directory and another in the root directory of the project.
Why Mercurial created these extra two APK files and how to get rid of them?
You have these two files in repo, clone just show it to you
You didn't see only these files in original Working Copy, because (not discovered yet) local settings for original workspace now ignore these files (after they was commited to repo - see hg log FILENAME), but adding to ignore-list doesn't mean "automatically forget and remove from repo"
how to get rid of them?
In cloned repo-root create .hgignore, add global pattern for all and any (?) *.apk-file
hg forget both APK (or Forget from CMenu of THG)
commit changes
remove files from WorkingCopy

Categories

Resources