How do I configure Araxis Merge for use with Git? - git-merge

I understand that Araxis Merge is now a "fully supported" mergetool for Git, so that much of what I can find about configuring Git to use it is now out of date. In particular, Araxis Merge should work "out of the box" simply by executing
git config --global merge.tool araxis
provided araxis is on my PATH.
However, for a several reasons, amending my PATH is not an option, so I need to be able to specify the correct path or cmd in .gitconfig.
How should I configure Git (on OS X) so that it finds Araxis Merge? Simply following the example of other tools like kdiff3 and p4merge with
git config --global mergetool.araxis.path /Applications/Araxis Merge.app/Contents/MacOS/Araxis Merge
doesn't work; nor does (guessing) with
git config --global mergetool.araxis.path /Applications/Araxis Merge.app/Contents/Utilities/araxisgitmerge
git config --global difftool.araxis.path /Applications/Araxis Merge.app/Contents/Utilities/araxisgitdiff
How should I configure my araxis.path? Are there additional Git settings that should be used with Araxis Merge?

Git now uses the Araxis compare utility directly, rather than araxisgitdiff and araxisgitmerge, so all that's needed is to set the path to
/Applications/Araxis Merge.app/Contents/Utilities/compare
for example, by executing
git config --global mergetool.araxis.path '/Applications/Araxis Merge.app/Contents/Utilities/compare'
or by directly editing ~/.gitconfig to contain
[mergetool "araxis"]
path = /Applications/Araxis Merge.app/Contents/Utilities/compare

Hard to make sense of the thread here, so I'm pasting below the exact .gitconfig that worked for me:
[diff]
tool = araxis
[merge]
tool = araxis
[mergetool "araxis"]
path = /Applications/Araxis Merge.app/Contents/Utilities/compare

Make sure you are running git version 1.6.4 or above. Copy these utilities from the Utilities folder in the Araxis Merge install image to /usr/local/bin.
araxisgitmerge
araxisopendiff
compare
compare2
Then edit ~/.gitconfig and add these lines:
[diff]
tool = araxis
[merge]
tool = araxis
The next time you type git mergetool it should launch the Araxis Merge graphical tool.
This information was taken from the official Araxis documentation here.

#raxacoricofallapatorius great answer! But you need to run that command line with quotes (due to the space in Araxis Merge. Without quotes produced a truncated path of "/Applications/Araxis" which didn't work obviously, but adding quotes and re-running that command fixed my issues. Thanks!
Fix:
git config --global mergetool.araxis.path "/Applications/Araxis Merge.app/Contents/Utilities/compare"

If you use SourceTree (I'm using v3.0.8) it's very easy to configure Araxis merge as the external diff tool:
For using Araxis Merge to view file differences:
Install Araxis Merge
In SourceTree: Tools > Options > Diff > External Diff Tool > select AraxisMerge from dropdown > OK
(No need to define the Arguments, no need to restart SourceTree)
Example use:
Right-click an uncommitted file that you want to compare > select 'External Diff' (or select file then CTRL-D) - this will compare the differences between your latest changes and your local repo.

Related

IntelliJ IDEA shows freshly checked-out files from GIT as changed while there is no difference

Like in the title, after checking out repository from GIT, the files are shown as changed (blue) by IntelliJ IDEA.
But they are not.
How to fix that?
What causes the problem is probably one of those:
line-ends converted / or not to CRLF (on the fly)
changed file mode
ignored / or not case
Here is why that may happen:
IntelliJ IDEA is using a different Git than the one that was used to check-out the files
Check which Git is in the System Path and which is in Settings > Version Control > Git > Path to Git excutable.
git --version may be useful too to check versions in different contexts
Even if versions are the same, what makes the difference is the configuration
git config --list shows what parameters were set
In my case, the Git version was the same, but from two different paths (one came in the package, one was installed independently). The configuration was different (default vs adopted) and that was enough to make everything quite confusing.
Especially check:
core.autocrlf=true (mainly on Windows)
core.filemode=true
core.ignorecase=true

git command to check if a repository has any uncommitted changes

I need to know if there is a git command using which I can check if there are any uncommitted changes present in a branch for a given repository
If you are only interested in files which are part of the index, the following command shows concise info
git status -suno
http://supercollider.sourceforge.net/wiki/index.php/Developer_cheatsheet_for_git
refer this link for git commands.
show uncommited local changes:
git diff [file]
You might as well use gitk - The Git repository browser

Intellij delete multiple local branches

Using Intellij IDE (I have version 2017.3.5) is there a way to delete multiple local git branches at once
You can delete multiple branches in IntelliJ IDEA directly.
Go to tab Git / Log. There open the Tree view on the left side. Check this picture:
Source: https://youtrack.jetbrains.com/issue/IDEA-131571
// Update Feb 2021:
As mojmir.novak pointed out here: https://stackoverflow.com/a/65954247/1546042 you can do this now in IntelliJ. To remove only merged branches, see answer below:
// Older update:
To clean-up (old) feature branches that have been merged to master you can use the terminal to clean it up.
To delete all local branches that are already merged into the currently checked out branch:
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d
See https://stackoverflow.com/a/6127884/1546042 for more details.
Cleaning up using run config"
In order to clean up multiple branches at once, using intelliJ. You need to install the Bash Support plugin and use it to create a run config that executes a script with the above command.
Install BashSupport plugin
Create script with the command. (e.g. ~/scripts/clean-branches.sh)
Create a new Bash run config.
Link to the script created in step #2.
Provide working directory of the repo you want to clean.
Run it to clean the branches.
There is a Plugin available for this:
https://plugins.jetbrains.com/plugin/10059-git-branch-cleaner/
To use it once it's installed, in the main menu go to:
VCS > Git > Delete Old Branches
Have been through the pain of cleaning up the unused branches, and found this plugin.
https://plugins.jetbrains.com/plugin/10059-git-branch-cleaner/
But I was not able to see the VCS > Git menu on my Mac - IntelliJ
But was successful in finding a similar option under git > context-menu - Delete old branches...
I am not sure if there is a default option or this is because of the above-mentioned plugin.
Sharing to help others who don't have VCS > Git menu like in my case
It's easy to delete multiple branch on Git Extensions.
http://gitextensions.github.io/

remove the file from git but keep it locally in intellij

Using command line, I can use
git rm --cached $FILE_PATH
In intellij 2017, I can add a file to the git index with the context menu, but it does not have the option to remove but keep a file in the index.
Typing the command is painful as a lot of java files are buried in nested directories.
There are no plans to add such a feature, see https://youtrack.jetbrains.com/issue/IDEA-107359
Moreover, IntelliJ cannot commit such a change, cause it calls git commit --only - see https://youtrack.jetbrains.com/issue/IDEA-138847

Getting current Git commit version from within Rails app?

How can I retrieve the current Git commit version from within a Ruby on Rails app?
Want to display the Git version (or maybe the last 6 letters or so) to serve as an App version.
Like #meagar said, use backticks to execute the shell command from within your app, but you may find these two commands more useful:
Full hash:
git rev-parse HEAD
First 7 characters of hash:
git rev-parse --short HEAD
You can invoke the git command from within your script:
commit = `git show --pretty=%H`
puts commit
Depending on your environment you may want to use the full path to the git binary, and possibly specify the GIT_DIR via an environment variable or --git-dir.
A more robust solution would be git show --pretty=%H -q. The -q flag quiets the output.
In order to remove the newline that is part of the output, you can use chomp. For example: system('git show --pretty=%H -q').chomp
The selected answer has the potential to actually return the diff when the commit is not a merge commit. Verified on git version 2.16.2.windows.1.
I presume that you want to include the app version in your HTML somewhere? The prerequisite is that you are deploying your repo with Capistrano in the default manner (you are uploading the repo, not sending up an archive file).
You can add some code to the Rails initializer as outlined here. That approach will get the SHA1 from the last commit, and make it available as an environment variable.
The other way to do it is have you Capistrano task generate a static file in the public directory with the commit SHA in it. You could include other info in this file that seems useful.