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.
[diff "xltrail"]
command = git-xltrail-diff.exe
[merge "xltrail"]
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!
I wrote a short blog post about how to use SourceTree with git-xltrail: https://dev.to/fzumstein/how-to-diff-excel-vba-code-in-sourcetree-git-client-36k
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Mike Corsaro @fzumstein What follows isn't technically an answer, but I figured it would make sense to keep a related beginner xltrail/sourcetree question in the same (and only similar) thread.
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
--- 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
End Sub
Sub CallCompareResults()
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Probably in the 2.7 release, which will be coming in the next few weeks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A couple weeks is pretty good, thanks!
Should those issues be brought up to them? Or do you think you can handle it on your end?
As an aside, I would've thought color formatting is handled by SourceTree?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Mike CorsaroIs there any update to this out of curiosity? Is it still slated for the next release, and if so do you know when that is coming out?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
[1m--- a/Book1.xlsb/VBA/Module/Module1
[1m+++ b/Book1.xlsb/VBA/Module/Module1
[36m@@ -2,3 +2,7 @@
'test1
Sub test()
Debug.Print "hello1"
[32m+End Sub
[32m+
[32m+
[32m+gsdgdsg
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @Mike Corsaro , I think what might happen is that @Kade333 is looking at two historical commits, while you're looking at pending commits (where it works). Is there anything we'll need to change (I am one of the maintainers) to make it work for historic commits, too?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@fzumsteinnothing you need to do on your side -- looks like 'diff-tree' doesn't have the default diff settings of '--ext-diff' like 'log' and 'diff' does for some reason. I'll add it to our backlog and hopefully it will be included in the next release.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey @fzumstein , your blog is great and very helpful. I recently started developing VBA and started to use Sourcetree along with my other Java projects. I can't wait to be able to compare historical diff's.
@Mike Corsaro , Any ETA on the timeline for this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It's been fixed in 3.1.3 which is at 25% in our progressive rollout. You can also manually download it here.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Cool.Thanks
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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?
Andrew D
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello! Sourcetree doesn't currently support doing this as we explicitly disallow external diff drivers for specific file types. However, I don't see why we couldn't support this as it's a pretty small change for us to make.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey, just wanted to throw my support in for this as well! It would be so nice to be able to use xltrail + Sourcetree's diff viewer.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.