I'm working on an application and managing its repo on bitbucket.
During the development process, I created a new branch 'price-module' a few days ago and pushed its changes in the remote branch by the same name. Now, when I'm merging 'price-module' to 'master' branch, bitbucket is showing me an error that there are conflicts between some files. (specifically in bin/R.txt). How can I resolve these conflicts and merge the changes I did in 'price-module' to 'master' branch without losing my code?
PS: the project I'm working on is an Android project.
Update: what have I tried so far to solve the problem
I did some research on my own to try and solve the conflict between files. These are the steps I took to solve the conflict:
Switched to master branch, manually overridden the conflicted files by copying them from 'price-module' branch (they are mainly gen or bin), pushed them to master and then tried to merge 'price-module' into 'master' -- FAILED!
Added Android-specific rules in exclude file in my .git folder from this answer but the gen and bin folders kept showing up.
In an Android project, you should not be storing the bin folder in version control in the first place as it contains only generated files. Though R.txt isn't one of them, there's R.java in gen/your/package/name.
Assuming it's the generated bin folder, you should remove it from git, add it to .gitignore so it doesn't show up as non-versioned in git status, merge or re-apply the deletion to both branches, and just let the build tools generate bin files as needed.
For more things to not put in version control, see Typical .gitignore file for an Android app
Related
I'm building a voice recording app and right now I'm backing up all of my code to GitHub and a memory stick. Whenever I make it build it saves it into the file directory that GitHub desktop it's backing up, but it won't detect some of my files. Such as: app.iml and app-debug.apk.
Has anyone else had this problem and if you have fixed it could you tell me how?
Those files shouldn't be committed or relied on since you will need to rebuild the project anyway when you do a fresh checkout. Your code might be different than your compiled code depending of how you added them. Check out this thread that talks about javascript Should compiled JavaScript files be committed to Git repo?
Sounds like Git ignoring files and directories specified in the .gitignore file in the root of your repository directory.
See lines from one of my repositories:
*.iml
..
..
/build
Your apk file is just the latest build of your code, so the source code saved to GitHub is the backup.
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
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.
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
I am currently using Git on the command line to help me incrementally add features without breaking existing code. The part that worries me is this line of output from Git after committing:
[optimized_managed_event 6c9a98c] Added managed event insert into my ContentProvider
12 files changed, 202 insertions(+), 16 deletions(-)
rewrite bin/classes.dex (87%)
rewrite bin/classes/com/zeroe/SmartCalProvider.class (85%)
Should I worry about the rewrites if they are .class files and other types that aren't text? I am fairly new to Git, but am pretty comfortable with the command line and I understand the basic workflow for most Git projects:
> git add .
> git commit -m 'comment on commit'
> git checkout [master]
> git merge [branch]
What I am slightly worried about is issues that can occur when committing, then merging since Android projects have a lot of files that it creates itself in different formats.
My question is essentially in anything I need to worry about when doing this in Android development?
Create .gitignore in the root of your project and add at least the following:
*~
*.apk
bin
gen
local.properties
.apt_generated
This way you avoid putting in repository automatically generated files, which usually blows the repository size up without any reason. The only automatically generated files you might want to save are proguard/ files, which might be necessary to unroll the call-stack after the user-generated crash reports.
Also, I found it's very helpful to have giggle utility installed to see what changes you have in your files.