Search code examples
gitgitignore

Is there a way to push specified files in the .gitignore file to origin?


I don't want some files to be tracked by git and I'm excluding them with a .gitignore file. but I want to push them to the origin branch because they are necessary when someone clones the project.
Now the question is can I do this without adding and committing the excluded files. I found this answer on StackOverflow. but I guess maybe git has a better solution for this.


Solution

  • I summarized your question here:

    Is there a way to push specified files in the .gitignore file to origin without adding and committing the excluded files?

    Unfortunately, there is not. You can git add --force the required file and then push it, but that's not what you asked for.

    If you're trying to set up a project that requires API keys or other secrets, I recommend including instructions on how to acquire them in a README.md file in the project.