I don't want to upload the following directory to GitHub in the app I am currently creating, so
I wrote the following in the .gitignore file:
[.gitignore] *sample_app/.gitignore
/app/views/categories/
/app/views/chat/
/app/views/question_mailer/
After that,
git add-A
git commit -m "add_.gitignore"
git push-u origin master
has been performed.
However, when I checked GitHub, the directory in the ".gitignore" file was uploaded to GitHub.
Is this the wrong way to write the .gitignore file?
If there is a mistake, please tell me how to write correctly.
Thank you for your cooperation.
.gitignore
is, as the name suggests, a specific directory file to be excluded from Git, so
If you want to remove a file that you committed before writing .gitignore
, you will have to gitrm --cached
, but of course it will remain in your previous history.If you want to delete the file, you have to go back to the point where you added it, or use git filter-branch
if the amount is large.
I don't want to post the above directory when I push GitHub, but is there a way to do it? Is there another way to do it with .gitignore?
The Git mechanism is that when you push, it is copied on a per-commit basis, so you cannot push only some of the files in the commit.Also, Github does not have the ability to keep certain files private.
Therefore, there are many cases where you either give up and publish it or leave it out of Git's control, and sometimes you separate the repository for private use and public use.
© 2024 OneMinuteCode. All rights reserved.