I have an existing Visual Studio project file (appsettings.json) that contains sensitive data that I do not want to publish to GitHub.
A repository is not currently created but I would like to create one without including the appsettings.json file.
I know that I can use the .gitignore file to exclude files after the initial push, but at this point the sensitive file would already have been pushed.
Moving forward, I can create the repository from the start of the project, but how should this be handled for an existing project without a repository?
I know that I can use the .gitignore file to exclude files after the initial push
Actually, you can use it before the initial push, even before the initial add to the index.
Simply create in VSCode a .gitignore at the root folder of your project, with as a content:
/.vscode/appsettings.json
(assuming this setting file was created automatically in the .vscode/ folder of your VSCode workspace for this project)
Then add and commit: you won't see that file in your first commit, than you can then push.
In visual studio,
Goto the solution explorer
Right click the file you want to git ignore
Goto "Git"
Then select "Ignore and untrack item"
I did the above to my appsettings.json and this is the entry i found in the .gitignore at the end of the file.
/MyProject.WebApi/appsettings.json
Here, "MyProject.WebApi" is inside the main directory.
Related
GoogleService-info.plist, Development.xcconfig, and GlobalVariables.swift have all been added to the projects .gitignore file.
Upon cloning the project from GitHub, all of the ignored files in the setup folder are greyed out.
The files should not be contained in git, as developers are to create them upon cloning the repo, add their own private keys (based on their own firebase backend), in order to do local development.
Issue #1:
Currently, the ignored files still appear (but greyed out), and developers must first delete the files, before recreating them. (this is due to the ignored files still persisting in the project.pbxproj file).
Issue#2:
The deletion & recreation of the files causes a change to the projects' project.pbxproj file, specificically, the files are recreated in project.pbxproj with a different fileRef number.
Issue#3:
Merge conflicts due to different fileRef numbers:
If two developers both clone the repo, both delete the 'greyed out' files and recreate them, the recreated files will have a different fileRef in the project.pbxproj file.
Each developer will have to perform an additional commit to account for the changes in the project.pbxproj file, and upon pushing the code to the remote repository, there will be a merge conflict in the project.pbxproj file.
The goal of adding the files to .gitignore was to keep each developers added code secrets out of git (Which it is still currently accomplishing).
However, is there a way to ensure that files added to .gitignore are also kept out of the ```project.pbxproj`` file?
Goals:
1) The files in .gitignore should not appear in the Setup folder upon cloning.
2) The creation of the files that have been added to .gitignore should not be added to the project.pbxproj file at all
3) Developers should effectively be able to clone the repository and create the setup files without any changes occurring in Git.
Any feedback on how to accomplish this is appreciated in advance.
To Clarify:
The files added to .gitignore are properly being ignored by git, the issue is that the created files are still being added to the project.pbxproj and persisting there, where they ideally should not be.
Suppose we have a project A with output directory bin/ and a project B with output directory test/bin/. Project A needs to have a certain configuration file copied to its output directory. Currently, this is being done by adding a pre-build event that looks like
COPY /Y "$(ProjectDir)..\config.ini" "$(TargetDir)"
Project B has A as dependency. When project B builds, the binary resulting from A is correctly copied to the output directory of B, but the config file isn't!
How can we achieve that all files that A needs to have are also copied to the output directory of B?
What you want is a Link File. I've used these before to ensure that connection.config files are copied to multiple projects.
I created a sample solution that mimics your described scenario as seen below. The ConsoleApplication1 references the ClassLibrary1 project. In the solution, I created a solution folder config and added the shared config that needs to be copied.
In order to have a single file that is copied across multiple projects, you must create a single file, and then add it as a link to the projects that need it. This can be done by right clicking on the project, and choosing Add -> Existing Item.... You will see a dialog as show below and you want to choose the Add as Link option from the dropdown instead of just Add.
Finally, edit the properties for the linked file to copy it to the output directory.
I am setting up a team project under git source control, and all members of the team will be using different IDE-s. The project is a basic command line application written in C. Personally I want to work within Xcode7, but I have a problem with the xcodeproj file (or folder) which is also being committed. I dont want this, since other team members dont work with Xcode and this xcodeproj file just does a mess when they checkout. I just want to be able to commit my regular source files to git and nothing else. What should I do? If the answer is .gitignore file, how should it look?
Just add these two lines to .gitignore:
*.xcodeproj/
DerivedData/
The first line excludes the Xcode project directory. The second excludes the default directory created for object files and other build data.
I have a brand new Visual Studio 2015 project stored in a TFS Git repo. I've configured a build using the standard Default Git build template. The new project builds locally just fine, but fails during the TFS Build with the following error:
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\build\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props.
When TFS first creates your Git repository, it includes a default .gitIgnore file which "hides" certain files from your your (Pending) Changes window. One of the wildcard based exclusions in the default .gitIgnore file specifically excludes any files from being checked in under any folder that includes "build/" which includes this specific file. For now, I've commented out that exclusion in the file, and now it shows up in my (pending) Changes window.
My team created a project. This project has already existed on each PC of each member. Now, I have just added this project to SVN using AnkhSVN. So I want to know how to each memeber of my team can use this project without check out or download this project because it has already existed. I want to using any SVN client to refer to it or something like that. Any idea for me ?
Short answer: they have to use SVN checkout into empty folders, sorry.
Ask your team members to:
create new folder named "fromsvn",
make an SVN checkout of project into that folder,
copy with replace existing project into "fromsvn" folder,
commit changes if there are any.
Long answer:
During checkout SVN creates folder named ".svn" in each folder. This ".svn" folder contains the so-called "base" versions of your files. Each "base" version is a copy of the original file which is inside SVN.
When you make "clean" checkout (i.e. you download project from server into empty folder using SVN client), SVN creates both "base" versions of files (and puts them into .svn folder) and "working copy" - the ones you actually will modify and then commit. Thus, if you checkout 10Mbytes project, SVN will create 20Mbytes of files, half of which will be stored in ".svn" folder, but it will download only 10Mbytes from server.
Other members already have their projects, but they do not have ".svn" folders. It means, that SVN client still have to download those folders from SVN server repository, and it will still cost those 10Mbytes.