How to get Git on Windows to ignore symbolic links - windows

I can't get this to work.
I have cloned a repository that has a dummy file (named src): /path/src.
On Windows I have created a symbolic link: mklink -d /path/src /otherplace/src (but I of course had to delete the dummy src file first).
In both my .gitignore and .git/info/exclude I have
/path/src/
/path/src
path/src/
path/src
And I have tried
git ls-files -s | gawk '/120000/{print $4}'
git update-index path/src/ --assume-unchanged
but I still get:
error: readlink("path/src"): Function not implemented
error: unable to index file path/src
fatal: updating files failed
I have tried all these other suggestions. And even this doesn't work.
Any ideas?

You can do a checkout ignoring this single file like this:
git checkout HEAD . --no path/src
The .gitignore file only works for adding stuff to the index. Even a modifications on files commited before adding it to the .gitignore are not ignored.

I know this is late, but I ran into this issue.
In my case, I apparently had checked in my symlink at some point. So no matter what I did, .gitignore would not work (I think that is what Alexandre was getting at).
REPAIR:
Remove all symlinks
See if git now thinks there are deleted files to commit.
If so, then go ahead and commit the deletions.
Now you can re-add your symlinks and .gitignore should work.

Here are my steps for this issue, similar, but a bit different from other answers.
Let's say I had a folder .fvm contain file.json and flutter_sdk(link) that all commited in git before, then I want to ignore out flutter_sdk.
Add .fvm/flutter_sdk and .fvm/flutter_sdk/ in .gitignore.
Cut .fvm/flutter_sdk out to other place than the repository.
git add . and git commit ....
Paste back the link.

Related

Can't get Xcode / JUCE / .gitignore to work

I'm placing my .gitignore file in the same location as the *.jucer file and the .gitignore file contains:
./Builds/*
./JuceLibraryCode/*
As I only want to back up the source code folder only.
But whenever I go to commit, tons of of folders and items inside the Builds and JuceLibraryCode folder are pre checked. How Can I get Xcode to see this ignore file? Is it in the wrong location since the Projucer builds the folder hierarchy in a way that Xcode doesn't understand? I have it in the same location as my .git file.
Also, its worth noting that I recently allowed .git to back up everything, all of the files I'm currently trying to now ignore in those folders, but I did do a git rm --cached on all the files I'm trying to skip, as i read I needed to dump those before the .gitignore would be successful, but still, not luck. Any help would be greatly appreciated.
Remove git cache again.
$ git rm --cached -r .
Add this in .gitignore
Builds/
JuceLibraryCode/
See if git ignore the changes
$ git status

Git clean single untracked file

I would like only a certain file to be untracked unlike
git clean
which will remove all untrack files. Thus what is the best way to do that.
Thanks.
Delete it (with rm or whatever facility your OS provides for deleting files).
If you want to keep the file, add it to the repo's .gitignore file, and Git won't try to track it anymore.
#mlpadi answer is correct as well. In this case though what I was looking for was
git clean -f {dir_path}
It helped me clean the files from that 1 folder it was complaining about

Untrack all files on git

In the move from C9 to hosting on my Macbook via SSH, I've had to re-download Kohana and change some other things just to get my site working; I don't want those to be committed. Is there any way to untrack all tracked files so only future changes are committed? Or is there something else I should be doing?
I'm on a Macbook running Mountain Lion with Apache and PHP turned on.
Even simpler:
cd /root/directory/of/your/local/repo
git rm --cached -r .
^^^
(space - dot)
Even even simpler:
git clone url/for/Kohana /different/local/path
git rm --cached File
Will delete the file in the index, so it will no longer be tracked, but won’t physically delete it. This will untrack the file only for current branch
[OR]
Use this git command. After you do this, git stops checking the file for possible modifications.
git update-index --assume-unchanged <filename>
At any time, you can track again by setting --no-assume-unchaged flag
git update-index --no-assume-unchanged <filename>
But these command do not affect the remote repository.
I'm not exactly sure what you mean by "untrack all tracked files so only future changes are committed". As you need to track files so they can be committed.
If all you just want to do is not track Kohana and the other downloads, then just remove them from your working directory using git rm --cached <file> or even better create a .gitignore file.
There are many helpful posts on stackoverflow to assist you with creating a .gitignore file for your project. By using this, you can exclude an entire folder easily.
For Mac, it would also be helpful if you could see hidden file as the . file is hidden. This page shows you how to see hidden files on Mountain Loin - http://www.mikesel.info/show-hidden-files-mac-os-x-10-7-lion/

Changing case of Folder via Git bash on Windows

I need to change the case of folders and files. First thing I tried was renaming the folders, but Git didn't pick up the changes. So I tried using git mv -f controller Controller but it says :
fatal: renaming 'application/classes/controller failed: Permission denied
I have tried setting the global ignorecase flag:
git config --global core.ignorecase false
But it still doesn't work. Some people have suggested to move the folder out of repo, delete, then re-add but would this change get picked up when other people pull the repo? Is there anything else I could try?
Edit: It works for files but not folders.
In summary of the comments, you'll have to rename the directory via a intermediate temporary name. E.g.
git mv controller Controller-tmp
git mv Controller-tmp Controller
I think this has to do with the fact that the MinGW implementation of rename(2) does not support this operation. See this thread, the MSDN docs on the CRT rename implementation and those of the MoveFileEx function.
Make sure to close Visual Studio and any Windows Explorer folders related to that path.
Make sure to add the changes to index after rename folder with intermediate folder as below.
git mv oldfolder newfolder
git add -u newfolder
git commit -m "changed the foldername whaddup"
Reference
I could not resolve this apart from performing the following
Branch from commit before folder name case changed, as a temp branch just to resolve this issue.
Cherry picking commits in order resolving folder case name changes before committing.
Reset old branch this new temp branch final commit.
Remove temp branch.

Case typo on path in msysgit

I went out to my github repo and discovered that I had inadvertently added files to msysgit with a typo. Instead of adding files to a directory called "Domain", I added them to "DOmain".
I tried git mv, but the path is case-insensitive in Windows and the move fails.
What's the best way to resolve an issue like this?
mv to something else, like "tempdir", and then mv back to the proper capitalization?
Go back in history (git checkout someHash), create new dir with proper case, checkout the files from the wrong commit (git checkout someWrongHash someFiles), commit them, and then, reset HEAD to the new commit.
(And next time, don't torture youreslf with git on Windows ;) )

Resources