When using Git, or really any source control system, you don’t want everything in your SalesLogix model to be under source control. There are some files that the Application Architect uses for it’s own purposes and volatile files that have no importance for your purposes and are recreated as needed. These files that change often with no importance to what you’re working on can make things difficult when working with source control since every time a developer pushes changes, that are pulled by another developer these files will need to be merged. Doing this every time will get old fast. Git has the built in ability to exclude files from source control. Let’s take a look at how.
The .gitignore file
Git uses a simple text file, named .gitignore, that you can use to enter file names, paths, or file name or path patterns to exclude from your Git repository. These files will still exist on the file system. Git just won’t keep track of them and won’t include them when you push changes. This way, each developer can have their own file that is independent of what you’re working on. This .gitignore file is nothing more than a list of files & paths that are not being tracked by Git and will be ignored. To create a gitignore file all you need to do is create a text file and then place it in the root of your Git repository – in our case it will be the root of your SalesLogix model folder.
What to Exclude from a SalesLogix Model
As I mentioned earlier, there are some files in a SalesLogix model that you don’t want to include in the Git repository. These are the main items to exclude:
- ModelIndex.xml – This file is a temporary cache created by Application Architect as you access objects. This file can be deleted and will be automatically created again as needed. This is a volatile file and if included in source control would require constant merging with no benefit.
- ModelDeployment folder tree – The deployment folder in the model is where the Application Architect will create all of the actual SmartPart.ascx files and other deployable items from the QuickForm meta data and entities in your model. This is not to be confused with a “deployment” per se, but this is a staging area for things to be deployed that are created when you build your platform. As you create, modify, delete items in the model and then build your web platform all of the deployment files are generated based on what is in your model. Including these files in your source control system will complicate things since these files are created all over again as you build your web platform. We’ll include this entire folder tree and everything in it.
In addition to those files, there are some files that is good to exclude as well. These are files that can be left behind by file merge & compare tools.
If you’re using Visual Studio and creating external assemblies for use within your SalesLogix model (if not you should be), then you’ll also want to exclude these files and paths as well.
Lastly, I like to force the inclusion of everything in the SupportFiles, just to make sure nothing gets left out (the exclamation point tells git to *not* ignore these).
Let’s see what the .gitignore file looks like with all of that together.
The Complete SalesLogix .gitignore File
This is what the complete .gitignore file would look like for a SalesLogix model:
# Files created from merge tools *.BACKUP.*.xml *.BASE.*.xml *.LOCAL.*.xml *.REMOTE.*.xml *.orig # Model files that are auto-generated [Mm]odel[Ii]ndex.xml # Temp deploy files [Mm]odel/[Dd]eployment # Visual Studio files *.suo *.cache *.obj *.pdb *.user obj/ [Dd]ebug*/ [Rr]elease*/ # Force include SupportFiles !Model/Portal/*/SupportFiles/[Bb]in/ !Model/Portal/PortalTemplates/*/SupportFiles/[Bb]in
You just create a text file, paste that in, and save it as “.gitignore” in the root of your Git repository. You can download this file zipped from me here:
When Should You Use a .gitignore File?
Seriously. Every project should have a .gitignore file. There is always something you want to exclude. Or should exclude. If you don’t think you need one then you might not be thinking forward enough to understand how files you’re adding will effect merges for other developers. Even if you’re just a single developer today, you never know what the future will bring.
Adding the .gitignore file right at the start of the project will save you many headaches later. Once a file is tracked by Git, adding it to the .gitignore won’t remove it from Git control. You have to manually remove the file from Git control, then it can ignore it. Also, if you add the .gitignore after other developers have pulled the repository and have made changes, you’re really going to screw things up since when they pull, and get your .gitignore file, and they’ve modified files you’ve told Git to ignore – clear your afternoon. You’ll be practicing your cursing skills. So, always remember, add the .gitignore before you ever do your first commit, and for sure before you do your first push.
Using Git Extensions for SalesLogix
If you’re using Git Extensions for SalesLogix, it will automatically create the .gitignore file for you, with the entries I mentioned above. You can read more about that here: Excluding SalesLogix Model Files from Source Control