What should I not upload to GitHub? - visual-studio

I've been working on a public Visual Studio project in GitHub, and have been uploading the entire solution folder into the repository, with all files. Are there specific files or folders that I should refrain from uploading to my repository? I've heard that certain folders can contain cache or user information, but I'm still not sure what to remove.

I always generate my .gitignore file with this website.
If you are working on an ASP .Net project and have connectionstrings for a DB in your appsettings, never push this to github. Best is to generate a appsettings.example.json and only have the structure and propably some default values in there.

Broadly speaking, you should not upload on github following:
any content which does not legally belong to you, and which has no some open source license.
content which could be generated (e.g. object files).
Specifically in your case
You can put source files in the repo but not things generated from the source.
Also, you should not commit class files. You should commit your build scripts, but not files generated by the build.
Lastly keep in mind the size limitations of 100MB per file.
Read also Hello World · GitHub Guides (https://guides.github.com/activities/hello-world/#what)

You can use the .gitignore file to ignore the IDE's config and build cache and the .env files. In particular, it is useful to write .env file to .gitignore to avoid some credential leaks caused by hard coding.
GitHub and the community provide common .gitignore rules, see https://github.com/github/gitignore.
Example:
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

Related

c# DocFx. Direct way to create the web page or pdf of documentation?

I have my visual studio 2022 project with c# and I want to create the documentation but I don't want more files and folders to my project.
Docfx create folders and files.
SandCastle you even have to create another project inside your solution.
There is a way to run a command and generate the web page without creating any extra file in the project/solution?
Thanks.
If you are just wanting to generate documentation from your source code xml comments than DocFx does not require that many new files to be be checked into source control. Sure you will need the basic project structure but all the intermediate / generated files in the output can be excluded from your committed source code using .gitignore files (assuming you are using git).
For example, in these tutorials
https://dotnet.github.io/docfx/tutorial/walkthrough/walkthrough_create_a_docfx_project_2.html
https://dotnet.github.io/docfx/tutorial/walkthrough/walkthrough_create_a_docfx_project.html
You would only really need
docfx.json
index.md
toc.yml
api/index.md
api.index.yml
.gitignore
If you add the following lines to the generated .gitignore from tutorial 1 then all the intermediate and generated documentation yml files will never be committed to git.
api/*.yml
api/.manifest
Hopefully this helps, I know it does not get you 0 extra files like you asked but its a fairly light weight solution to generating api documentation.

IBM Rational Rhapsody Generated Files

I am trying to create an IBM Clearcase development view with a Rational Rhapsody project and need to classify all the private files as checked-in files or generated files.
From what I know all of the .cpp, .h and .o files are auto generated but there are several other file formats I cannot find information on. Does anyone know what a .ehl ,.rpw, .save, and a .log files are used for? I have been moving files into far off directories and compiling but it takes hours and the help files do not mention these.
Thank you
You can see the list of types of files which should be (or not be) under version control at "Content management files for Rational Rhapsody".
They are also listed at "Project files and directories".
In particular:
*.ehl Events history list, which stores animation commands, such as event generation
Does not require configuration management.
<Project>.rpw Workspace settings file. Preserves the workspace settings for the project.
Usually not versioned (private to the user's environment).
load.log A log of when various repository files were loaded into the product, including any errors that might have occurred during the loading and resolution phases.
store.log A log recording when the project was saved.
Both logs shouldn't be versioned.

Should git ignore the *.pch files created by XCode?

Should I add *.pch files to .gitignore in XCode projects?
No, you should not. It's not a generated file, you as a developer may (and should) modify it. The point is to put the most commonly used #import/#include directives in here. That will speed up compiling as Xcode will then precompile it and GCC will use these "cached" results when compiling other files without the need to parse and compile those includes over and over again.
I found the speedup to be especially dramatic with C++, BTW.
To add a bit more context to the question - What files should you consider ignoring in a VCS?
Personal settings files such as *.pbxuser. These are things that contain the settings for your personal environment or workspace. Not much use to anyone who clones the repository and of marginal use if you are using a repository across machines
Generated files. If your project generates files then there is no point in having them in your repository because unless you are always generating them, they end up out of date. This is why you frequently see build/ in the .gitignore file
Files that contain passwords or access tokens. Pretty obvious, really.
Put it simply. Don't ignore anything that your project requires to build. The PCH file is referenced in your project settings and you'll get a build error if it doesn't exist in the project so it really should be in the repository.
No, they're important to the project.
They're prefix headers and will be imported to every file within the project.
I don't use git, I use svn but the ignore settings should be the same. When I set up a project, the only things I ignore by default are:
the build directory
*.pbxuser and *.mode1v3 in the xcodeproj bundle.
Everything else (including the pch file) is something that should be under source code control (unless you add other generated files outside of build).

Is there a sensible way to backup Visual Studio C++ solutions without all the "extra" files the IDE creates?

I would like to make a backup of my project, but the folder now exceeds 6.6 GB mainly through extra libraries like boost etc, but even if I just select the folders with my sources, I end up with big files like: .ipch, .sdf and potentially others. To make matters worse I use eclipse to code and VS to compile, so that adds to the mess, although I have the impression that only VS creates big files.
In case shit hits the fan I would like to be able to unpack one archive, and have everything in there like the project settings and solution files, and the sources so that I can easily open it again in VS. I can live with having to re-download boost or other third party libs.
How do you tackle this problem and do I need to preserve file like .sdf?
Answer:
Thanks for all the tips. I will now adopt the solution proposed by LocustHorde because that seems to fit my needs best. I simply want one file that I can take offsite as a safe backup (and I don't want to use an online service). Storing all versions of all files doesn't seem to work towards smaller and simpler and it would be a bit overkill in this case, although I will look to install some version control system because I have no experience with them and I would like to get some...
Final Answer
After having a good look I found that dishing out which files had to be ignored by the winrar archiving was still a hassle. I finally ended up installing Git out of curiosity and liked it. So I now have some of my projects in a local repository. From eclipse I can easily mark files and directories for being ignored, and to make a backup I use git-extensions to clone the repo. I still need to look at purging old versions, which isn't very userfriendly in Git, but seems to be possible at least and then i will just 7zip the folder up. In the worst case I just delete the git database and I just have the last version of my source files. Or maybe I can checkout to another directory. We'll see.
First: Instead of doing a backup, I would strongly recommend using a version control system (VCS) like Subversion, Mercurial, or Git. This is the professional equivalent of a backup, except it maintains every version of every file—not just a copy of the latest version.
Even with a VCS, you will still need to decide which files to check-in to the VCS, and you don’t want to back up files that can be easily re-generated.
For my projects, I generally don’t check-in:
Generated executables (the output in the Release, Debug, x64\Release, and x64\Debug directories).
Pre-compiled headers (the ipch folder)
The browsing database (sdf files)
All of these things can be re-generated by rebuilding your project. If you are working as part of a team, you probably shouldn’t check in:
Your personal settings (.suo)
You can always re-create this if needed.
A particularly nice way to backup your stuff is to put your source in a revision control system. I am using git sometimes, and other times mercurial. Using git I can ignore the files that should not be backed up, by adding them to .gitignore:
Debug
Yokto.sdf
Yokto.suo
*.filters
*.user
ipch
Release
Yokto.opensdf
*.opensdf
*.sdf
With git I can set up a backup repository on a network drive and simply push to it every now and then.
you can write a simple script (batch file) that only zips the types of files you want. suppose, you want to zip all your .aspx, .cs, .config, .xsd files only,
suppose you have winrar installed in your c:\program files\winrar
and your project is in c:\project\MyBigProject
then, just open your notepad, copy paste this, and save as "script.bat" (dont forget the double quotes while saving, you need to save it with double quotes, so that notepad saves as .bat extention instead of .txt)
so to backup (in other words, to zip wanted files) :
"C:\Program Files\WinRAR\rar" a -r0 -ed MyBackup.rar c:\project\MyBigProject\*.aspx,*.cs,*.xsd,*.config
the syntax is like this:
"path to winrar folder" 'switches' "Name of completed rar file" 'folder to zip'
just make sure the paths are in proper order. the "a -r0 -ed" parts are switches, and you can find out all about the switches here:
http://acritum.com/winrar/manual/index.html?html_helpswitches.htm
I use the "Ignore files" switch (http://acritum.com/winrar/manual/index.html?html_helpswxa.htm) to ignore all files and folders that I dont want (with wildcards) and My project is about 86 mb, when It gets compressed just with code files, it comes up to 6mb.
its the best way to do it really. If you need more help, please ask!
edit: Also, Look into SVN (its free!) - I use svn too, and its really helpfull. there is even a free tool called AnkhSvn to integrate into visual studio. its just fantastic!
Doing a "clean" before archiving removes most of what you don't need.
Edited to add:
Of course a version control system is essential for any ongoing project, but that's not what he's asking.

.sbr files in Source Control

I just started working on my first Visual Studio project, and I imported all the existing code for the project into an SVN repo of mine without checking which files were binary and which weren't. So now I'm trying to clean up the repo and I've come across some .sbr, .pch, and .res files.
I figure the .pch file doesn't need to be in source control because it's binary. But the sbr and res files are currently empty, so I can't tell offhand if they should be in the repo. So should they be in or out?
.res files are compiled versions of .rc files, so they don't need to be in the repository either.
After removing all the files you don't believe are necessary (most non-text files except images are probably not necessary), you should check out your project into a clean directory and attempt to do a full build. If it fails, then you removed too much. (If it succeeds, then you may be able to remove more stuff!)
They should not be in the repo. They are all intermediate files created during compilation.
Res may be necessary since they can contain resources. SBR is source browser and should be created on compile if you're using the /Fr option (I think).
Edit: Never mind, I assume the poster above me is correct. Make sure you have the .rc/rc2 files then.
.pch files are pre-complied headers and do not need to be included in SVN. They will be recreated when you check out your codebase and and do a build.

Resources