While working on .NET projects, I analyzed that most of the developers make some common mistakes while committing code to SVN. So, I have identified those common mistakes and collaborated them as SVN guidelines to be followed for .NET code. Those are as follows:
- We should not check in the debug files like .pdb files etc.
- We should not check in local settings file.
- We should not check in local DLLS.
- We should not check in bin and other local folders.
- We should not check in debug and published folders or any other information like “My Project” folder.
- We should not check in our solution files (.sln) until and unless we have added or removed any vb project.
- Never commit .suo file.
- We should not check in .vbproj file until and unless we have added or removed any file, sub-folder or reference to that particular project.
- We should not check in .vbproj.user file as it is local system specific file of user.
- Always remember to commit .vbproj file if you have added or removed any file, sub-folder or reference to that particular project. But before committing the code take a diff of this file and include only file information and not any unnecessary information like compile time changes or local reference changes etc.
- We should not check in web.config until and unless there are some code changes that are not user machine specific.
- Similarly if you are adding or deleting a project, then always remember to check in .sln file but before that take a diff and check in only the required changes of file and not the local version information.
- Always take a difference of all the changes in your folder before you check in. If you are using Tortoise SVN client, then you can follow the below steps:
- Go to the parent folder of your repository.
- Right click -> Tortoise SVN -> check for modifications
- This will open up a window listing all the files, folders that are modified
- Please keep in mind, to check the “Unversioned” which will also display the newly added files in your repository.
- To include newly added file, you have to right click that particular folder or file and Add into the SVN before commit. If you created new files and/or directories during your development process then you need to add them to source control too. Select the file(s) and/or directory and use TortoiseSVN → Add. If you add a file or folder by mistake, you can undo the addition before you commit using TortoiseSVN → Undo add….
- If you want to delete some file or folder, you need to right click and Delete into the SVN before commit. When you TortoiseSVN → Delete a file or folder, it is removed from your working copy immediately as well as being marked for deletion in the repository on next commit. The item’s parent folder shows a “modified” icon overlay. Up until you commit the change, you can get the file back using TortoiseSVN → Revert on the parent folder
- you want to delete an item from the repository, but keep it locally as an unversioned file/folder, use Extended Context Menu → Delete (keep local).
- If a Subversion command cannot complete successfully, perhaps due to server problems, your working copy can be left in an inconsistent state. In that case you need to use TortoiseSVN → Cleanup on the folder. It is a good idea to do this at the top level of the working copy.
- In projects you will have files and folders that should not be subject to version control. These might include files created by the compiler,
*.pdbmaybe an output folder used to store the executable. Whenever you commit changes, TortoiseSVN shows your unversioned files, which fills up the file list in the commit dialog. The best way to avoid these problems is to add the derived files to the project’s ignore list. That way they will never show up in the commit dialog, but genuine unversioned source files will still be flagged up. If you right click on a single unversioned file, and select the command TortoiseSVN → Add to Ignore List from the context menu.