git - gitattributes and the binary option - Stack Overflow
Be a Git ninja: the .gitattributes file by Pablo Reyes ...
git recursive merge strategy options within .gitattributes
Open gitattributes file
Git - Git Attributes
Launch external difftool by file extension?
I would like my GUI of choice (SourceTree) to be able to launch more than just the default Difftool program when using the External Diff right-click menu command on a file. To that end, I want to be able to use git difftool and based on the extension of that file, open an external comparison program as I believe that is the command being passed to git by SourceTree. I can do this already with git difftool -t , unfortunately, SourceTree does not offer the ability to pass the --tool option.
What I've Tried:
Currently, my global config file looks like this:
# Differencing Configuration [diff] tool = WinMerge [diff "MyCompare"] command = \"C:\\Users\\\\.gitdiffdrivers\\MyCompare.cmd\" #This just tries to pass %5 and %2 to the same executable as the difftool entry binary = true [difftool] prompt = false [difftool "WinMerge"] cmd = \"C:\\Program Files\\WinMerge\\WinMergeU.exe\" -e -u -dl \"Old $BASE\" -dr \"New $BASE\" \"$LOCAL\" \"$REMOTE\" trustExitCode = true [difftool "sourcetree"] cmd = '' \"$LOCAL\" \"$REMOTE\" [difftool "MyCompare"] cmd = \"C:\\\\MyCompare.exe\" \"$LOCAL\" \"$REMOTE\" [SomeOptions]
The .cmd file is just: "C:\\MyCompare.exe" %5 %2 [SomeOptions] I have *.[Aa][Cc][Dd] binary diff=MyCompare in my gitattributes file. I also tried *.[Aa][Cc][Dd] binary difftool=MyCompare (changed diff= to difftool=) with no luck. Both just do a text based diff in the command line instead of launching the external program. I'm completely stumped.
I'm comparing large proprietary binary files (Rockwell Automation .ACD files) and the only program that is capable of comparing them is Rockwell's "Logix Compare Tool". Clearly I do not want to make this my default difftool and suggestions of other difftools that I could make my difftool besides WinMerge are pointless.
I was going back and fourth on posting this but I've seen a few people ask questions that this might help to answer so I figured I'd post it and maybe it will generate some discussion. I've been using Bitbucket to host my code repositories for some time now so when I started game development, it made a lot of sense to me to continue using Bitbucket and Git. At the time, there was no size limit on Bitbucket repositories and Git worked fine for my desktop and phone application development, so why not game development?
As it turns out, game development can have a lot more binary content than your applications depending on what you're building. The most recent game I'm working on, "Dungeons of Rune" is a 3D mobile game built with Unity. I decided that as a mobile game, the 2GB limit would be sufficient. Unfortunately, I was incorrect. Textures and audio are binary files that take up a significant amount of space as they are. On top of that, any time you update a binary file, Git needs to store the entire file again. Alone, this would be enough to cause trouble in the long term however I thought that would be manageable as I don't often re-update binary files too often as they're mostly sourced from the Asset Store. What I didn't consider is how assets from the Asset Store often contain many superfluous textures (and other files) that simply weren't relevant to my project. If I'd thought of this earlier, I could've just not imported/committed these additional files but that sounds like a lot of manual filtering and I feel it'd really slow down development.
Note: There's a nice writeup from Atlassian on handling big repositories with Git. There are a lot of potential solutions to this problem. All have pros and cons and take time to investigate and set up so nothing is a silver bullet like "download and run suspicious-package.exe to fix all your computer problems".
Move to a different Git repo host with no size limit
Visual Studio Online currently allows you to create free Git repositories with no size limit but there's no guarantee they'll stay that way. This would be a trivially easy change to implement. Sign up for an account. Define a new Git origin. Send the code to Visual Studio Online and keep my repository history! Despite solving an immediate problem, this doesn't solve the long term problem of having a massive repository. Checking out a fresh repository will take approximately "exactly one million years" due to multiple versions of binary files - though you can get around this with a shallow clone using the depth paramter. If Microsoft (Visual Studio Online) decide to impose a size limit, this could cause problems. They may take the same approach as Atlassian (Bitbucket) and "grandfather in" existing repositories so they have no size limit but there's no guarantee.
Separate Asset Store folders out into submodules
Git Submodules are a viable option and it makes sense not to have a monolithic repository when you have modular assets. In theory, asset packages could live in separate repositories since they're modular. Unfortunately, assets aren't that straightforward in Unity and their code doesn't always live under a single folder that would make a neat little submodule. So you could take this approach for some modules or for parts of some modules but it wouldn't be as clean as you might hope. The other problem is that initial cloning of the repository will still take as long as a single repository.
Change to a different version control system
There's a lot of talk about Perforce's P4D and using Subversion for version control of binary files. Everything I've read about P4D suggests it's ideal for game development and handles large repositories very well. It's also free to host a server for up to 20 users. If you're willing to run your own server, this may be a good solution for you. If you're not willing to run your own server, the options for hosted P4D repositories are relatively minimal. Assembla offer free Perforce hosting for up to 1GB repository size and 1000 files which isn't helpful for this use-case. Their paid plans do solve the space and file limit issues but they begin to get expensive if you only use source control ($24 per month for 5GB + extras as at 8-Feb-2015). Subversion is also an option. It's not a distributed version control system like Git so when you pull/update the latest changes, you only pull the files that you need and not the history. This means your server can still bloat but your local copy will feel relatively clean. Hosted Subversion repositories are also readily available. Some find merges difficult with Subversion so make sure this isn't a problem for you. Mercurial deals with large files in much the same way the Git extensions do as described below. There are various pros and cons of using different version control systems and much of these are personal preference. You'll have to do some more reading and decide for yourself.
Use one of the many Git workarounds to store binary files somewhere else
Using one of the tools below, you can continue to version your binary files with Git but the actual binary files will be stored somewhere else. What this means is you have a single Git repository that doesn't get bloated. What's the catch? First there's the set up. You need to have somewhere to host the files though there are often many options available there. Some may choose to synchronise via Dropbox or similar client apps, while others use hosted options such as Amazon S3. You will also need to set up your .gitattributes file for your repository to tell it which files need to be stored somewhere else and then there may be some other configuration depending on which option you choose. Second, there may be some additional workflow steps that you need to do such as pushing the binary files separately to pushing to your git repository. You may be able to use git hooks to do some of this automatically for you but the repos don't tell you how to set this up. Last, these tools have varying degrees of support and usage. They seem to work fine but you may run into edge cases down the road. I would suggest ensuring you have multiple clones/checkouts of your latest code+binaries at the very least.
git-annex - Probably the most comprehensive solution but also a little more complicated. Files are stored locally and need to be synchronised remotely. Git annex assistant
git-fat - Remote storage of binary files via Rsync
git-bin - Remote storage of binary files on Amazon S3
Confused about phantom "modifications" with certain binary files
This situation is a little complicated, so I apologize in advance. I've done everything I can think of and researched all I can find but still can't quite figure this one out. I work on a repo that has a large number of files with windows-style line endings. At some point some of the files were changed to linux-style. I suspect I did this inadvertently via cygwin and/or vim, but the initial cause isn't actually all that important. The problem is that some legacy applications I support require files to have CRLF line-endings. Rather than actually attempt to change the line ending on every text file in the repo, I tried a quick solution that did not work as expected. I tried putting a .gitattributes file in the root of the repo with "* text eol=crlf", since my understanding was that it was force all files to be CRLF. What I didn't understand at that time was that this relied on git determining which files were text and which were binary. This seems to have caused a situation where a number of false positives are being reported. Files are listed as modified when no changes have actually been made. After a fair amount of research into the guts of .gitattribute and line-endings and all that, I came up with a new .gitattributes file. This one specifically lists the required CRLF files and also a number of files that should be treated as binary. Unfortunately, I'm still getting phantom modifications on a few remaining files. What's strange is that all of these file extensions were explicitly marked as binary in .gitattributes. For example, in my .gitattributes (which I paste below) I have the line "*.exe binary" but even with that line I have several .exe files which show as modified. Further adding to the mystery, if I check out the "modified" files, the changes go away and everything is fine. I might be tempted to call this a suitable workaround but as far as I can tell there is no way to check out an individual file in the git client most of the team is using: Sourcetree. I found a workaround where you right click the file, view log, and reset to a specific commit, but it does not have the same effect as checking out the file. As an extra clue, in Sourcetree it's easy to open the before/after versions of files. I opened the "before" version of one of the .exes and it just opened with no problems. The "after" version prompted me to choose an application to open it with. This leads me to believe that the .exe has become corrupt through a process I don't understand. Any advice on this would be greatly appreciated. I'm trying to resolve this with a more specific .gitattributes file and ultimately need a solution git newbies can use. Thanks! My .gitattributes file:
*.Object text eol=crlf *.CS text eol=crlf *.Script text eol=crlf *.Project text eol=crlf *.actions text eol=crlf *.pm binary *.png binary *.PNG binary *.jpg binary *.JPG binary *.jpeg binary *.JPEG binary *.dll binary *.DLL binary *.exe binary *.EXE binary *.tgz binary *.TGZ binary *.doc binary *.DOC binary
tl;dr: On a windows system with the .gitattributes file listed above, git is indicating certain files are modified immediately after checkout. This applies to several filetypes that are explicitly listed as binary. On CLI git, checking out the file fixes it. Sourcetree does not seem to have a similar option.
The name of the driver is not important, as long as it's not one of the known magic names (text, binary, and union): Git will run your driver instead of doing its own file-level merge, when it determines that there is a file-level merge to be performed. The gitattributes documentation has this to say about defining a merge driver: Recommended software programs are sorted by OS platform (Windows, macOS, Linux, iOS, Android etc.) and possible program actions that can be done with the file: like open gitattributes file, edit gitattributes file, convert gitattributes file, view gitattributes file, play gitattributes file etc. (if exist software for corresponding action in File-Extensions.org's database). % cat .gitattributes foo.txt binary % git merge branch warning: Cannot merge binary files: foo.txt (HEAD vs. branch) Auto-merging foo.txt CONFLICT (content): Merge conflict in foo.txt Automatic merge failed; fix conflicts and then commit the result. However, if you want to allow the files to be automergeable but still keep the other effects of the binary attribute - namely, removing CR/LF ... Solve the diff visual problems on your pull request. Or select an automatic action when you have conflicts merging your branchs. For example your images, lock files, etc. One of the most important… #Set default behavior to automatically normalize line endings. # ##### * text = auto # Set default behavior for command prompt diff. # This is need for earlier builds of msysgit that does not have it on by # default for csharp files. # Note: This is only used by command line # *.cs diff=csharp A Dynamics CRM plugin to transparently store attachment binaries outside CRM database. Azure Blob or File storage for instance. - DawidPotgieter/Dynamics-CRM-Binary ... This will cause Git to generate Binary files differ (or a binary patch, if binary patches are enabled) instead of a regular diff. However, one may also want to specify other diff driver attributes. For example, you might want to use textconv to convert postscript files to an ASCII representation for human viewing, but otherwise treat them as binary files. Some of these settings can also be specified for a path, so that Git applies those settings only for a subdirectory or subset of files. These path-specific settings are called Git attributes and are set either in a .gitattributes file in one of your directories (normally the root of your project) or in the .git/info/attributes file if you don’t want the attributes file committed with your ... Thursday, 17 August 2017. Gitattributes Binary Options Put something like this in your .gitattributes file (create it if it doesn't exist): *.sln binary *.suo binary *.vcxproj binary Here binary is actually a predefined macro, equivalent to -diff -merge -text. If you want to still be able to see the diff, you can use: *.sln -merge -text This way, the *.sln files won't be merged, not have eol normalized, but meanwhile diff-able. share improve ...
Foundations of Programming (Python) Module 01 Part 2