Visual Studio gitignore and mdf, ldf files - visual-studio-2010

I have a database project that generates these files and added to gitignore. However they don't seem to be getting ignored and I need to revert them before commiting, quite annoying. The files are still locked by VS, is this a problem?
#
# Windows and Mac OS X Temp Cache Files
#
[Tt]humbs.db
*.DS_Store
#
#Visual Studio files
#
*.[Oo]bj
*.user
*.aps
*.pch
*.vspscc
*.vssscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.[Cc]ache
*.ilk
*.log
*.lib
*.sbr
*.sdf
*.dbmdl
*.mdf
*.ldf
*.Database.dbmdl
ipch/
obj/
[Bb]in
[Dd]ebug*/
[Rr]elease*/
#
#Tooling
#
_ReSharper*/
*.resharper
[Tt]est[Rr]esult*
#
#Project files
#
[Bb]uild/
#
#Subversion files
#
.svn
#
# Microsoft Office Temp Files
#
~$*
#
# YoureOnTime specific files
#
YoureOnTime.Database.dbmdl
# End of File

I need to revert them before commiting
indicates that they are already versioned and were entered into .gitignore after they were added using git add.
Two possible solutions:
temporarily take them out of your .gitignore, then
git rm --cached -- *.mdf and
git rm --cached -- *.ldf.
This will remove the files from the index while keeping them on disk. When done,
git commit -m "removing crap from repo" and restore your .gitignore.
If you don't want to play around with your .gitignore, you could use update-index:
git update-index --assume-unchanged -- *.mdf and
git update-index --assume-unchanged -- *.ldf.
This will force git to see the files as unchanged even if they were.

Related

How can I remove ~$ files using git bash (on windows)

I don't see the file in explored, even with the "show hidden objects" setting.
On the other hand git shows it as untracked files and I found no way to remove it.
Any ideas?
git status
On branch devSQC
Your branch is up to date with 'origin/devSQC'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
pathto/~$crazy file.xlsx
nothing added to commit but untracked files present (use "git add" to track)
ls pathto/
'~$crazy file.xlsx'
git rm -f 'pathto/~$crazy file.xlsx'
fatal: pathspec 'pathto/~$crazy file.xlsx' did not match any files
I know those are windows files for recovery, but windows does not allow to do anything either and I hope git bash is better ;-)
See e.g. here but I hope, I don't need to install additional tools...
I just realized, it is simple to remove those files within bash (of course, it has nothing to do with git...)
cd path2/
rm -f '~$FHS_Noten STAT_FS2019_TZ17_Noten_Vorlage.xlsx'
git-rm does not work because it
Remove files from the working tree and from the index
so it is not a function to delete files.

How can I make Xcode ignore xcodeproj in Xcode 9?

I have been working on a C project using Xcode9. I don't want to push my .xcodeproj directory into the GitHub. I use the source control menu inside the Xcode to sync with GitHub.
I have added the following line into my .gitignore file:
*.xcodeproj/
DerivedData/
*.pbxproj
*xcworkspace
but it won't work. When I commit, Xcode would still push my xcodeproj directory into the GitHub. How can I ignore these files in Xcode9.
That might be because those files are already tracked (making the .gitignore directive moot)
Try and remove them from the index
git rm --cached -r *.xcodeproj/
git rm --cached -r DerivedData/
git rm --cached -r *.pbxproj
git rm --cached -r *xcworkspace
The --cached option will make sure you keep those files on the disk (and remove them only form the index).

.gitignore for xcworkspace, not just xcodeproj?

I have a .gitignore file in MyProject.xcodeproj which ignores the xcuserdata, but the directory is not ignored in my MyProject.xcworkspace and I can't figure out how to do it there? Any suggestions?
Make sure the content of that folder is not already tracked:
git rm --cached [project].xcodeproj/project.xcworkspace/xcuserdata/*
git commit -m "Removed previously track xcuserdata content"
Then your .gitignore would apply automatically.

.gitignore files not working (ignore .DS_Store file in Mac OS)

I have create a.gitignore file at my ~ path by this code in my terminal:
touch ~/.gitignore
and also add this file and git defining excludes file by below code:
git config --global core.excludesfile ~/.gitignore
and then remove all of my .DS_Store file using below command
find . -name .DS_Store -print0 | xargs -0 git rm -f --ignore-unmatch
(every file has been removed successfully and if I open xCode and press commit the D label appears near this files)
Before I commit I add the .DS_Store to the .gitignore file by this command:
echo .DS_Store >> ~/.gitignore
it also works and write the value in the file but it is not working. Because when I back to xcode and commit the files and then back to finder and navigate to folders and back to xcode, I can see the .DS_Store files in commit dialog too.
Does someone have any idea about what is the problem?
After performing the
git rm
you still need to commit those changes
git commit -m "deleted all .DS files"
The next time you will ask git for a diff, these files will no longer show up as modified or "new" because they are in your global gitignore file

Gitignore doesn't work properly

I have follwoing dir structure
and here is content of .gitignore
conf.php
The problem is, when I change contents conf.php and try to commit something, GIT detects conf.php as changed file again. In fact it must be ignored.
I have commited it once. I want to ignore it from now. What am I missing?
Update
I tried following:
Added conf.php to gitignore
removed it from cache git rm --cached conf.php.
But now, when I rescan project, it wants to stage conf.php as removed.
Its not what I want.
I want to keep it on remote repo and ignore future (from now) changes in local repo.
Git will not ignore tracked files
Git will not ignore changes to already-committed files.
What Git ignore is for
Git ignore, ignores noise that's in your repo, for example:
$ git init
$ mkdir tmp
$ touch tmp/file1
$ touch tmp/file2
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# tmp/
nothing added to commit but untracked files present (use "git add" to track)
If the .gitignore file is modified to ignore the tmp directory:
$ echo "tmp" > .gitignore
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
nothing added to commit but untracked files present (use "git add" to track)
the tmp dir contents are nolonger listed - but the .gitignore file IS listed (because I just created it and the file itself is not ignored).
Committing that, there are no changes listed:
$ git add .gitignore
$ git commit -v -m "addding git ignore file"
[master (root-commit) d7af571] addding git ignore file
1 file changed, 1 insertion(+)
create mode 100644 .gitignore
$ git status
# On branch master
nothing to commit (working directory clean)
Now any changes to the .gitignore file will show up as pending changes, any new files outside the tmp dir will show up as untracked files and any changes inside the tmp dir will be ignored.
Don't commit files that you don't want to track
If you've already added conf.php to your git repo, git is tracking the file. When it changes git will say that it has pending changes.
the solution to such things is to NOT commit files you don't want to track. Instead what you can do though, is to commit a default file, e.g.:
$ mv conf.php conf.php.default
$ # Edit conf.php.default to be in an appropriate state if necessary
$ git commit -v -m "moving conf.php file"
$ cp conf.php.default conf.php
Now any changes you make to conf.php - will not show up as unstaged changes.
if you want to add a empty config file to your project and then not track any additonal changes then you can do this:
edit conf.php to be in the state you want it to stay
add and commit the config.php
run the following git command:
git update-index --assume-unchanged conf.php
You will no longer see conf.php as having pending changes
To start tracking changes again, run this command:
git update-index --no-assume-unchanged conf.php
Just run git rm --cached conf.php
If you have more commited files to ignore:
git rm -r --cached .
git add .
Then commit and push your changes.

Resources