2

Hey this does not work for me:

vendor/*
!vendor/predis/
vendor/predis/*
!vendor/predis/predis
vendor/predis/predis/*
!vendor/predis/predis/lib
vendor/predis/predis/lib/*
!vendor/predis/predis/lib/Predis
vendor/predis/predis/lib/Predis/*
!vendor/predis/predis/lib/Predis/Profile
vendor/predis/predis/lib/Predis/Profile/*
!vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php

Where did I make a mistake?

  • I'm perfectly able to reinclude a file in a subfolder as you are trying to do. Your mistake must lay somewhere else, for example a typo in some folder name which is impossible to diagnose for us. – Sascha Wolf Dec 16 '14 at 09:54
  • It should be some sort of configuration in my git. The path is correct – valerij vasilcenko Dec 17 '14 at 08:12

2 Answers2

1

What is your actual state of the repository?

I believe that what you want to have is just:

vendor/*

Prior to creating .gitignore file, just git add vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php. It will now be tracked.

After you create .gitignore file (or add the mentioned line to it) all untracked files in vendor directory will be ignored.

[EDIT] (Correction after helpful comments, thanks!)

Please keep in mind that you cannot ignore a file that is already tracked. If you want to do that, you need execute command git update-index --assume-unchanged against the files you want to ignore - but this change will be local to your repository, it will not be shared. For more details see How to ignore files only locally in git?.

Community
  • 1
  • 1
Piotr Zierhoffer
  • 5,005
  • 1
  • 38
  • 59
  • 1
    `.git/info/exclude` is in no way different to `.gitignore` except for the fact that it only exists for your local repository. It doesn't enable you to ignore already tracked files as you implied. – Sascha Wolf Dec 16 '14 at 09:44
  • 1
    See `git help update-index`, specifically the option `--assume-unchanged` for how to ignore changes to a tracked file. – chepner Dec 16 '14 at 13:18
  • My mistake, updating my answer (as it was a side note, not the core of it). – Piotr Zierhoffer Dec 16 '14 at 15:49
  • @PiotrZierhoffer, @Chepner, unfortunately the --assume-unchanged is not about ignoring the file, it's merely an indication to Git that you won't be changing it, so it doesn't need to expend cycles in some code paths to stat the files. Other commands will still notice the changes and do things you don't expect. The git documentation is being updated in the current change cycle. Try `--skip-worktree`. – Philip Oakley Dec 16 '14 at 20:37
0

create .gitignore with

vendor/*

then git add -f vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php

the -f option will ignore the rules in .gitignore, so the file will be tracked

leo108
  • 817
  • 5
  • 12
  • fatal: Path 'vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php' is in submodule 'vendor/predis/predis' – valerij vasilcenko Dec 17 '14 at 08:11
  • @hellomyfriends That's your problem: The file you are trying to track rests in a submodule. You can't seperatly track files in submodules. What are you trying to achieve then? – Sascha Wolf Dec 17 '14 at 08:18