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.
Related
I am having an issue while renaming a package and then pushing it to git remote repo. I used Intellij > Refactor > rename to rename the package, in local Git status is showing as renamed file but in github when raising a pull request it is showing that old package as deleted and new package as added.
How to resolve this and tell git to consider them as renamed ?
Example:
com.test.examplePackage ===> renamed to com.test.examplepackage (we have almost 500 files in this packge)
Now github is showing
com/test/examplePackage/Xyz.java -- deleted
com/test/examplepackage/Xyz.java -- added
Instead of com/test/examplePackage/Xyz.java ===> renamed to com/test/examplepackage/Xyz.java
Similar question has been already answered here:
How to make git mark a deleted and a new file as a file move?
In short, Git will consider the file/directory deleted if the content was modified beyond certain treshold. For this reason you may want to do separate commits for just renaming, and separate for changing file content inside.
Another factor that may be relevant in this case, is that when merging using squash your separate commits are bulked into one, which may explain the different behaviour locally and in github - commit squashing may be turned on by default in your repo.
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.
I am using git for the first time and I am trying to make a commit. I want to ignore all .project and .settings files so I went to my .gitignore file and added .project, .settings and saved. When I did that the .settings file doesn't appear anymore, however, I still see my .project file when I do git -status. Also, why is the .xml and java file in a different section that the .jar files:
Your git status output is showing you two types of files:
Changes not staged for commit
These are files which Git is tracking, and these files have been modified since the previous commit. But, the changes have not yet been staged. Unless you stage the changes using git add, they will not be committed. Here is how you would stage the change to the web.xml file:
git add path/to/web.xml
Assuming you really just started working, then the most likely explanation for why the .project is showing up as being tracked by Git is that you somehow added it. To fix this, you can try using:
git rm --cached .project
This removes the .project file from being tracked by Git. It would also remove it from the remote repository, but since you just started working and haven't pushed yet, this is a moot point.
Untracked files
These are files which Git is completely ignoring. From Git's point of view, these files are not there. I can see that you have a number of JAR files listed as untracked, which is probably a good thing, since in general it is a bad idea to add binary files, especially dependencies, to your Git repository. Should you see a source file listed as untracked, you could also run git add to add that file to Git.
The reason it is generally considered bad practice to add binaries to a Git repository is that Git doesn't handle diffs of binaries very well. Suppose you add a 1MB JAR file. Each time it changes, which could be fairly often if you are doing some open source stuff, a diff has to be stored for that binary. But, Git often will interpret the diff as being deleting the old file and replacing it with the entire contents of the new file. In other words, Git basically versions the entire binary for each change. Over time, this can cause your repository to become large and bloated, and it can be difficult to get rid of those binaries from your history. So, unless absolutely necessary, avoid storing binaries in your Git repository.
I changed some settings in my config file which I don't want to push to the remote repository.
I want it to effect only one project locally.
I saw there are few ways to do so:
http://365git.tumblr.com/post/519016351/three-ways-of-excluding-files (1)
Per Computer: through settings in ~/.gitconfig
git update-index --assume-unchanged (2)
I'm using SourceTree and only when I use option (2) I see the files are vanished from the UI.
What is the difference between (1) and (2) ?
Does it really means that the files are not ignored when I see them in the SourceTree after using option (1) ?
The .gitignore file prevents files from showing up as files to be added to the repository. If the file is already in the repo when it is added to the .gitignore file, any changes to the file will be shown by git and can be committed. The .gitignore settings only affect new files that are in the repos path. You would use this for keeping temp files created by you IDE or compile files from showing up and cluttering your list of files that you modified when you do git status.
git update-index --assume-unchanged doesn't show that a file was changed at all. If you make any modifications to the file, git won't show that it has been modified in git status. You would use this with config files for users. When the repository gets cloned they need to have the file but there may be some changes that they need so that they can use the code (i.e. change a file path for their local machine). But you don't want them to accidentally commit the file and mess up things for others when they pull in the changes.
For changes to a config file, you want to use the git update-index option. You want the config file in the repo but you don't want to commit the changes to it.
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)