How to show gutter for git diff? - android-studio

In IntelliJ there is a gutter to the left of the text editing area that can show git diffs. I would like to have the same thing in android studio. Is there a way to make this appear?

I've run into this issue a couple times using Android Studio there are two reasons I've seen Git diffs not show in the gutter.
The Git VCS path for the project isn't set. You can typically set this in your project by going to:
System Preferences > VCS
Then hitting the + button and adding your Git root directory.
The project xml is borked. Sometimes a corruption exists some where in the code directory. Unfortunately, after hours of searching through XML in the .idea directory and other files and directories I was never able to find the culprit. However, simply deleting the project, pulling it down from source control and re-importing it into Android Studio re-enabled the git diffing in the sidebar.

If you already have the git-repository associated with project. And you just need to enable VCS, to be able to perform operations (pull, push, etc.). You need to select : VCS >> enable VCS. Then after, it is automatically able to understand the source-control associated with the project. You can validate, by selecting : VCS >> Git >> Branches.
NOTE : I had been using git for version-controling, hence it shows "Git" option in the VCS menu list. This may differ based on your tool.

Related

IntelliJ: Lost files after "Update project" and can't find them on Local history

I have a nodjs project and i use IntelliJ to run it. Lately the project structure is not appearing as it used to, as if the project was not compiling. So, while searching for answeres, I clicked on the "Update project" button on the right top, but quickly realised it was going to update based on what was on the remote repo.
I've been developing for a few weeks without a single commit because my company asked me to (don't ask why), and the code had sensible data so I didn't have a backup.
After clicking that button, IntelliJ asked me if I wanted to merge my project files with the remote ones, I just pressed Cancel, and that was enough for IntelliJ to merge my entire project and lose a bunch of files I've been working with.
Suprisingly, they're not even on the Local History list. Even though it says "279 files" there I can't click or find any of the files.
Despite not being able to find them, I went to the changes.storageData file under IntelliJIdea2017.2\system\LocalHistory, searched for the names of the files I'm looking for, and found them all there, which makes me think there's still a way of finding them.
So, does anyone know where I can find deleted files after pressing the git "Update project" button on IntelliJ when they're not on the Local History file list?
Thanks a lot in advance!
As I understand, the files were not committed, so Update could not delete them, because git merge/rebase do not start when there are uncommitted changes (see e.g. this question)
They were probably automatically stashed before the update, and not unstashed because the update was actually canceled.
So the first place to check is git stash VCS - Git - Unstash... or Shelf (if Update project is configured to use Shelf)

Open uncommited files in Android studio

I have been working on several java and xml files in android studio.
Now when done, i want to open the all modified files all at once to review them before a commit.
Something similar to git status and then git show for each and every one of them.
I can do it manually of course but i was wondering is there a better way to do that.
I think you are looking for the Local Changes part of the Version Control tab (Alt+9). There you can check the changes, though you need to open them one-by-one.
If you open (Ctrl+K) the Commit dialog, you can also check the diffs easily within the window, I find that very useful:

Highlight changes in code since last commit in Android Studio

Is there any way I can show changes that I made since the last commit in the code editor?
Use the Version Control tab. Under Log, you can select the first two changes, and use CTRL + D or Command + D to produce a diff between the two.
Note that this approach works best with code under source control that's registered with Android Studio. If you're not using any source control, you can still get a partial history of changes by navigating to VCS > Local History > Show Local History and selecting the root directory in your project. Note that this is subject to the Local History log length, which is nominally limited to 1,000 entries.
If you are using subversion Git then :
VCS->Git->Compare with the Same Repository Version
On the left side of IDE open "Project" bar and select "Changed Files"
In the menu:
VCS -> Subversion -> Compare with lastest repository version

Subclipse (1.8.5) requires cleanup / refresh cycle to detect changes made with TortoiseSVN (1.7.4)

My problem:
Subclipse does not update locked status overlay icons in eclipse after I lock/unlock some files with TortoiseSVN in windows explorer (and vice versa).
Is this expected behaviour or am I missing a setting?
The files have the svn property "svn:needs-lock" set.
I can sync Subclipse again by first clicking "Team - Refresh/Cleanup" and then "Refresh F5".
I am not a 100% sure but I think with Subclipse 1.6.x and TortoiseSVN 1.6.x I was able to just hit F5 in eclipse, and the status was refreshed correctly.
Thank you for your time.
I do not think you should have to do the second F5, but we added the Team > Refresh/Cleanup option for this reason.
With pre-SVN 1.7.x releases any change in the working copy caused files in all of the hidden .svn folders to be modified. When you hit F5 in Eclipse, it would see these changed files and fire off notifications that Subclipse would see and use that to refresh decorations.
With SVN 1.7, all this information is consolidated in a single location, and it sounds like it probably does not even live inside your Eclipse project folder. So F5 in Eclipse effectively does nothing because no files on the filesystem that Eclipse can see has been modified. Eclipse does not send out any notifications.
The Team > Refresh/Cleanup option calls the same Eclipse action as F5, but it also triggers an explicit refresh of SVN cached information regardless of whether Eclipse sees any changes.
Just to explain in more detail how to create the keyboard shortcut:
I was once pretty desperate to get this keyboard binding to work and after a lot of head banging found out that I also had to enable the "SVN Command Group" in my eclipse perspective (as explained here: SVN key bindings not working in Eclipse):
You can bind the F5 key to the "Cleanup/refresh" option of the SVN menu.
First,you must go to Window dropdown menu > Customize Perspective > Command Groups Availability and there check the SVN box.
With this option you will get a dropdown menu called SVN with all the relevant commands.
Then you go to Settings > General > Keys :
unbind the F5 key if you want to use this key
bind the command %CleanupAction.label to F5 or any key you may find useful (like Shift+F5 if you don't want the F5 key to be unbind.)

How do I create a patch from diff between revisions using TortoiseSVN?

I'm working on a project where Subversion is used to maintain version control. I use TortoiseSVN to access the project repository.
Some changes were made between two revisions on a project (let's call them rev1 and rev2), and I want to be able to apply these changes to a working copy somewhere that temporarily does not have access to the repository.
I right-clicked on a project folder, clicked 'SVN show log', selected the two revisions and selected 'Show changes as unified diff'.
This causes a window to be shown, displaying output that very much looks like a patch file that I could save. Unfortunately, I find that there is no option in the window that lets me save this as a patch file.
How can I create the patch file?
The next version of TortoiseSVN (1.7.x) will have that save option. In the meantime, you can configure a plain text editor as your unified diff viewer:
Settings dialog->External Programs->Unified Diff Viewer
There you could, for example, specify notepad.exe as your diff viewer.
One way to achieve you goal is to right click on the revision in the TortoiseSVN log and choose "Merge revision to...". Then you select you local working project and click OK.

Resources