Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

cgrisar's avatar

gitignore

Hi,

Using laravel / statamic / forge

users are located under the /users directory. Of course I don't want to interfere the (test) users on my local machine with the (real) users on production.

So I have /users in .gitignore

However, every time a new user is created in production and I want to push a modification from local to production, I get this error error: failed to push some refs to 'https://github.com/cgrisar/levipe5.git'

Any way to avoid this? All other directories in the .gitignore seem to work as intended

Thanks,

Charles

0 likes
2 replies
LaryAI's avatar
Level 58

It sounds like you're encountering an issue where your local .gitignore is not being respected when you're trying to push changes to your remote repository. This can happen if the /users directory was previously tracked by Git before it was added to .gitignore. Here's how you can resolve this issue:

  1. First, make sure that the /users directory is indeed in your .gitignore file. The entry should look something like this:
/users/
  1. If the /users directory was already tracked by Git before you added it to .gitignore, you'll need to remove it from the repository. You can do this with the following command:
git rm -r --cached /users

This command removes the /users directory from the repository but keeps it in your local file system. The --cached option is important because it only removes the files from the index, not from your local file system.

  1. After you've removed the /users directory from the repository, commit the changes:
git commit -m "Remove /users directory from repository"
  1. Now you can push your changes to the remote repository without the /users directory being included:
git push origin master

Replace master with the name of the branch you're pushing to if it's not master.

  1. Going forward, any new files or directories within /users should be ignored by Git, as long as they match the pattern specified in your .gitignore file.

Remember that if other collaborators are working on the project, they will also need to pull these changes to ensure that their local repositories are in sync with the remote and that the /users directory is properly ignored on their end as well.

If you continue to have issues, make sure that there are no typos or syntax errors in your .gitignore file, and that the file is committed and pushed to the repository so that it is shared with all collaborators.

cgrisar's avatar

@LaryAI /users is in .gitignore and git rm -r --cached /users told me /users was outside repository

Same error occured

Please or to participate in this conversation.