0

I have an Angular project where I'd like to push only some files into my remote repo via Git. Modifying .gitignore and using the .git/info/exclude didn't work. I'm sure it stopped Git from detecting changes in those places, but these files still got pushed to the remote repo even after creating and pushing a new branch.

How can I exclude, for example, my entire e2e folder from being pushed to the remote repo? node_modules already behaves this way, as it only exists on my local and wont get comitted to the remote. How do I do that for other files and folders?

phd
  • 82,685
  • 13
  • 120
  • 165
Kyle Vassella
  • 2,296
  • 10
  • 32
  • 62
  • 1
    If the files are already tracked by git and *then* you ignored them, they still get tracked. You can remove them from getting tracked with `git rm --cached folderOrFile`. – kelsny May 19 '22 at 21:05
  • @catgirlkelly Does this only take effect for the branch in question, or will this untrack these files for all branches? – Kyle Vassella May 19 '22 at 21:32
  • 1
    Tracked-ness of a file is a property of Git's *index*. The index is filled in from a commit. The branch name is not relevant: all that matters is what is in the *commit* in question. You will need to make a new *tip commit* in all branches that have a tip commit that contains the files. Note that switching from a commit that contains the files, to one that lacks the files, causes the files to be removed, so while this solution *works* it may have undesired side effects. – torek May 19 '22 at 21:41

0 Answers0