Certain Java files in Android Studio not showing up on GitHub Desktop - java

I have a project in Android Studio, and whatever changes I make in the application in Android Studios usually shows up in GitHub Desktop to push. Below is a screenshot of a history of revisions I've made:
However, at a certain point, I've made java classes in the application that are not being accounted for in GitHub Desktop. The classes that I am unable to push to my repository are highlighted in yellow:
Is there any solution to this?

Follow the commands:
Go to root directory of project and run git status to list uncommitted files.
Run git add . to add all the files to track.
Run git commit -m "your message" to commit files in current track.
Run git pull origin branch_name to get updated data from that branch. (branch_name is your current branch name.)
Run git push origin branch_name to push all committed files.
Now you check status by git status Hope all files will be uploaded.

Have you run git add on the new files? You can't push new files if you don't add them first.

If you are still looking for the answer.
I had the same issue while using Android Studio. In my case .gitignore file at the repo's main directory had a line that pointed to /app folder of my project. I just removed it and problem solved.
In general, you can have multiple .gitignore files so follow the below steps to fix this type of issue:
Go to your root directory of the git repo.
Search for all .gitignore files (In my case I found 3 files. )
See which of the files is causing the issue by simply commenting all the lines of a file.
Once you have the identified the file, now search for the line that is pointing to the files that you are interested and remove it.

Related

Necessary files not showing up on github for android project

enter image description here
I'm new to android studio. Every time I share a new project on github, some of the necessary files and folders (settings.gradle, gradle/wrapper and .idea folder, gradlew, gradlew.properties,gradlew.bat) needed for someone to clone my project are not showing up on github, making it impossible for me to be graded remotely as a student.
The only files showing up are the app folder, the .gitignore, build.gradle, and gradle.properties files only.
Please help!
You can find out why certain files like the gradle wrapper are ignored by using git check-ignore --verbose gradle/wrapper/gradle-wrapper.jar.
Afterwards, you just need to adjust the relevant config file and remove the arbitrary lines. In your case (as I can see from your last comment on the original question), the .gitignore file in your user directory is the problem.

Processing Jars in Eclipse

I have recently started working with a friend on eclipse, using Processing.
All the commits are fine and we can Push and Pull them correctly, but there is one problem:
We import an external jar from proccessing ("Core.jar") which is saved on each one of ours computers.
Every time that we Pull a new commit, ("Core.jar") directory changes and we have to remove the jar and reload it so we can Run the code.
Ive searched about gitIgnore but I do the ("Reset Option" and the "Ignore option") but it doesn't seem to work since the Jars problem is again.
I use Github Desktop.
As commented, if that jar is versioned instead of being generated or loaded, you should remove it from the repo first:
You can open a command-line from GitHub Desktop, and type:
git rm --cached -- Core.jar
git add .
git commit -m "record Core.jar deletion"
git push
Then your .gitignore rule should be immediately effective.
Said .gitignore should include "*.jar", or at least "Core.jar" (without the double-quotes)

Git doesnt show diff for some files in pull requests

I'm using Bitbucket for reviewing pull requests.
The files(happens to only css & jsp) shows modified but only shows first line modified & doesn't highlight actual changes. I literally have to get raw files from feature branch and remote branch to do comparison.
I also later added a .gitattributes to force git to diff files as text instead of binary. I tried adding below in my .gitattributes file but that didn't seem to work.
In my .gitattributes file:
# Web
*.css text diff=css
*.css diff=css
Its likely a git issue as I tried fetching the pull request locally to my local branch and then compared with the remote branch and I noticed same problem as i see in Bitbucket.
Please help.

Deleting file from Bitbucket causing issue for ignored files

I performed number of steps (some mistakes and then correcting them as shown below) and it's now causing issue in Eclipse resulting in not allowing me to switch from master to branch1.
Below is the sequence of steps:
Created master branch and pushed code including .project file by
mistake.
Created branch1 from master and pushed some code there.
Realizing mistake that .project file need not be committed, I switched back to master branch and used
"git rm --cached .project" command to remove that file from repo. Though
on terminal, it showed "rm '.project'", it would still show on bitbucked
repo.
That gave me impression that the file was not removed from repo so I
went to Bitbucket UI and removed that file externally from bitbucket
(.project -> Edit -> Delete).
That deleted my file from repo.
Went back to Eclipse and made a pull request from Eclipse itself. No error was shown.
But now
when I switch to branch1 from master, it's not allowing me to switch
and shows the error:
I put that file in .gitignore file as well (by including /.project) and pushed .gitignore but in vain. It gives me options of "Reset", "Commit" and "Stash" but unfortunately none of them works probably cause git knows this file as "ignored file" / "untracked file". I tried all of them one by one (quite a few times) but this pops up all time.
Any help would be greatly appreciated.
I'm not sure if this is the "ideal" answer but I think, from the command line, you could do a forced checkout of branch1 from master, do a git rm of the .project file and then push the change (the deletion of the .project file) to the remote repo. So it would look something like this:
git checkout -f branch1
git rm .project
git commit -m "Deleting .project dir"
git push origin branch1

How do I do commit a renamed file with case-sensitive using TortoiseGit?

I am trying a sample project to rename a file using Eclipse. First, I did a commit and pushed to GitHub. The file was Samplemain.java. If I rename that file to SampleMain.java and if I try to commit the renamed file using TortoiseGit, I'm unable to commit. Instead, it's showing an error with a small dialog.
Please let me know the solutions for renaming files with case-sensitive in Git.
I am using Windows, the error dialog is shown below.
This is a problem with TortoiseGit, not with Git itself. If you commit using the command line it will work, I checked it now. Note that renaming still takes 2 git mv commands, but only one git commit, as it should.
Another alternative is to rename the file on GitHub: when editing a file on GitHub notice at the top that you can change the name. After that you can pull from it.
Run following command in Windows command line (MINGW console). It should fix the case detection problem.
git config core.ignorecase false
Two-stage rename... name it to something like 'z.tmp' then back to the name your really want.
I know with Subversion I have to commit between two-step renames, but with Mercurial I don't.
Not sure if Git needs it or not.
There's a utility made for this apparently: https://github.com/tawman/git-unite
I haven't been able to try it myself yet, as the author doesn't provide the final exe files, and I had an issue when trying to run the build script. But it seems to be a utility that would solve this issue more easily.
It searches for name-casing mismatches between repo and folders, and updates the repo to match the folder, letting you then commit with only one version of the files. So just change the names in Windows explorer to what you want, then run the utility, I believe. (maybe followed by a commit -- not sure)

Categories

Resources