I have been developing some VBA Macros in Excel and I would like to use revision control to help manage the development.
I have discovered https://www.xltrail.com/client which is an open source Git command line extension: git-diff and git-merge.
It seems to work great from the git command line. However, I am used to using SourceTree. Anyone know how I can merge these two together?
Under git I tried system git instead of embedded. I also tried playing around with the external diff/merge options. I couldn't seem to get it right.
xltrail added the following to my .git/config file if this helps.
command = git-xltrail-diff.exe
name = xltrail merge driver for Excel workbooks
driver = git-xltrail-merge.exe %P %O %A %B
I am a beginner with Git and SourceTree. Any help would be greatly appreciated.
Hi @Mike Corsaro I am one of the maintainers of git-xltrail. I see that it now works with SourceTree 3.0.12. However, I can only see it working in the case of uncommitted changes, not for already committed changes. Is there a simple reason for why that is? We're happy to do changes on our side as per your suggestion but I was wondering if the current behaviour was expected. Thanks for a quick feedback!
Just to minimize confusion: We have renamed git-xltrail into Git XL and hence all commands are now "git xl" instead of "git xltrail". Everything else stays the same, but during upgrading it might be best to completely uninstall git-xltrail before you upgrade to git-xl.
Along similar lines to OP I'm a relative beginner with Git, xltrail, and SourceTree, and I've been playing around with using these tools to manage some xlsm files.
Everything seemed to be working swimmingly, but I ran into some trouble when I edited a VBA module in one of my xlsm files and then observed it in Sourcetree.
When I try to stage or discard lines/hunk, I get the following error:
The content of that file is:
diff --git a/diff_results.xlsm b/diff_results.xlsm
@@ -11,8 +11,8 @@
' Return code?
Call RunPowerShell(cmd, "CompareResults")
[31m-' dummy comment added
[32m+' dummy comment revised after being added
I verified that I could discard hunk with a change to a simple text file, so I think my basic sourcetree and repo setup is right. Perhaps xltrail doesn't support patching like this? Or might something else be the problem?
Just to provide an update on this one -- it's going to take a bit longer than expected due to xltrail not producing a standard git diff:
Thanks for your patience!
I have installed xltrial and it works as intended in the command window as intended.
Unfortunately, it is not showing up in the GUI window as shown here.
I am running version SourceTree version 3.1.2.
Is there something else I am supposed to to in order to get this to work, or are you still working on the patch?
Seems to work fine for me?
Are you sure you have everything configured?
Open the Process Log (Tools > Process Viewer...), click on the file to generate the diff, and then check the process output. It should look something like this:
[1mdiff --xltrail a/Book1.xlsb b/Book1.xlsb
[36m@@ -2,3 +2,7 @@
@Mike Corsaro , thanks, I was struggling to make SourceTree (v3.2.6) work with that but couldn't and after I posted a question here it started to work)
Actually I believe there is still a problem in some cases: there is one command (from the logs) that is not calling Git XL and the other command is calling it and producing a proper diff output.
The command #1 that works - as it is in my SourceTree log file:
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks diff-tree --oneline --unified=3 --root -w -M -C --ext-diff 6b4...3b7 -- \"Test_GitXL/Variation.xlsm\"
This command #2 doesn't work with Git XL:
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks diff --unified=3 -M --no-color -- \"Test_GitXL/Orica Contract Variation.xlsm\"
"Output" of second command is : "diff --git a/Test_GitXL/Variation.xlsm b/Test_GitXL/Variation.xlsm\nindex 0a51..1fec 100644\nBinary files a/Test_GitXL/Variation.xlsm and b/Test_GitXL/Variation.xlsm differ\n"
Output from command #1 is meaningfull diff results...
Possibly I'm missing something in my Git knowledge, can't see why #1 works while #2 doesn't.... difference is that #1 has diff-tree and ext-diff... but what does that mean?
For what it is worth, that would be a huge help to me.
SourceTree is a critical part of my development for all of the other languages I code in. Being able to use SourceTree for my VBA development would be a huge win.
I still use it, but not being able to use diff and merge limits its usefulness.
Thanks for considering this!