In my newest .NET Core ASP.MVC project I seem to be unable to ignore the restore.dg file. By default, the Visual Studio .gitignore file is set to ignore the whole .vs/ folder, in which the file is located. As this did not work, I tried several methods how to get rid of the file, yet unsuccessfully.
# Visual Studio 2015 cache/options directory
.vs/
restore.dg
*.dg
.vs/*
Could somebody help me?
Remove it from the cache.
git rm --cached .vs/restore.dg
git commit -m "Remove restore.dg from the cache"
See also: How to make Git "forget" about a file that was tracked but is now in .gitignore?
This might happen after you have already committed this file into the repository. If this is the case you have to remove it using git rm --cached <filename> command and commit this change to the repository. After that it will disappear from git status and will never bother you again.
Related
I want to stop cloning my application files to Github, How can I do that completely and remove the circle status on each solution files?
Environment: Visual Studio for Mac
Are you intending to have git ignore those files completely?
You can use a gitignore file (.gitignore) in the root working directory of your project to specify which files to ignore. In there, specify a filename per line in that file, or a whole directory to be ignored (eg: Shared/*).
You'll also need to remove those files from your git repo, since they've already been committed.
Copy-pasting from here:
Unstage the file
git reset HEAD newfile
Remove the file from git
git rm --cached newfile
Deleting the file will count as a commit, so you'll need to git push once you're done.
Also note that the file(s) and their contents will still exist in the git commit history, so this isn't a good idea if the goal is removing files with sensitive info.
I want to exclude the changes in all files in a folder Api\Bin*.* and Core\obj*.* into GitHub merging. I dont want to consider that folder while merging the changes. How can I do that Please advise. I have added the following line of code in ignored file from Repository->Setting->Ignored files , but not working . When compile the program , still obj and bin folder files is showed in changes of GitHub
You can add a line in gitingore files following ways
logs/
These lines will ignore the logs folder. Even you can use patterns.
If those files are already tracked, no amount of .gitignore would work.
You need to remove them first (from the Git index, not from your disk)
git rm --cached -r API/bin/
git rm --cached -r Core/obj/
Then check (no commit needed) if you see them in GitHub Desktop.
You can also see if your .gitignore rules apply with:
git check-ignore -v -- Core/obj/<anObjFile>
I'm trying to ignore obj, bin, debug type files/directories from my Visual studio project. I've followed the advice here:
ignoring any 'bin' directory on a git project
This is not working.
I've pasted the entire git ignore here:
https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
This is not working.
I've tried all sorts of things...
bin/
obj/
*bin/
*obj/
/bin/
/obj/
packages
MyProject/MyProject/obj/
MyProject/MyProject/bin/Debug/
MyProject/MyProject/obj/*
MyProject/MyProject/bin/Debug/*
The directories and their files are still being included when I run a git add. The .gitignore file is added and commited. What am I doing wrong???
EDIT: The files I'm trying to ignore aren't already being tracked. When I run a "git status" there are no pending changes. "nothing to commit, working tree clean". Then I run my VS program which modifies the files in those folders. Then I run another git status and all of the files show up as "modified"...
EDIT2: Does it matter if the files already exist? They are not being tracked but DO exist in the folder structure. When when I run the program they show up again as "modified". Then I have to run a "git checkout ." to remove them all. Then the cycle repeats...
If your file was already been tracked and committed before adding in .gitignore, it won't ignore it. You would require to remove it from index to stop tracking
For file
git rm --cached <file need to remove>
For Folders
git rm -r --cached <folder>
So that would be an issue in your case since Jenkins is still able to see the file in the repo
Hi look at the edit part ,
If you already have any folders in your git index which you no longer wish to track then you need to remove them explicitly. Git won't stop tracking paths that are already being tracked just because they now match a new .gitignore pattern. Execute a folder remove (rm) from index only (--cached) recursivelly (-r).
git rm -r --cached yourfolder
Based on your "Edit 2" above, it sounds like you don't think these have been previously committed, but in reality, they have been. If it shows up as "modified", the git is recognizing the file has changed from the last version it has checked in. If the file was not already committed previously then it would show up as Untracked.
When you are running git checkout on those files, you are telling git to revert those files back to the last version that was checked into git.
In GitHub for Windows, files that have been git rm --cached still appear in the list of changed files. Is there any way to hide them?
You still need to add the files to your .gitignore file.
http://www.gitguys.com/how-to-remove-a-file-from-git-source-control-but-not-delete-it/:
The git rm command will allows you to remote a file from git control.
The –cached option to git remove allows you to leave it on your hard
drive.
Every once in awhile a file gets checked into git that isn’t supposed
to be there. Common examples are configuration files, project files
generated by your IDE with personal settings and even the occasional
object file that someone decided to check in. These files are needed,
so often you can’t delete them entirely and the process of copying
them somewhere else, removing them from git and then replacing is
painful, not to mention prone to error.
By adding the –cached option to the git rm command, you are able to
remote the file file from git control while keeping the file in your
working tree. They command syntax is:
git rm --cached file
Git will no longer track this file even though it is still on your
hard drive.
After running the above command, be sure to add an entry to your .gitignore file so that ‘file’ doesn’t show up in ‘git status’ and that it can’t accidentally be re-added later.
In .gitignore under the same directory there is
.factorypath
/.factorypath
added for eclipse project. But whenever any change occur in this file it is still visible as modified under git or smartgit.
Any idea why ?
Most likely the file .factorypath was added to git before you excluded it in .gitignore. From the gitignore documentation (http://git-scm.com/docs/gitignore):
NOTES
The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.
To stop tracking a file that is currently tracked, use git rm --cached.
To show files currently tracked by git you can use git ls-files.
As stated in the quote above to stop tracking the file use:
git rm --cached .factorypath.
This will keep your working tree copy of the file but remove it from the index.
It's because the file was previously tracked. With that in mind, this question already has been answered here.