How to use gitignore command in git

前端 未结 7 789
天命终不由人
天命终不由人 2021-01-29 18:27

I\'m working first time on git. I have pushed my branch on github and it pushed all the library and documents into the github. Now what can I do and how can I use gitignore comm

7条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-29 18:46

    So based on what you said, these files are libraries/documentation you don't want to delete but also don't want to push to github. Let say you have your project in folder your_project and a doc directory: your_project/doc.

    1. Remove it from the project directory (without actually deleting it): git rm --cached doc/*
    2. If you don't already have a .gitignore, you can make one right inside of your project folder: project/.gitignore.
    3. Put doc/* in the .gitignore
    4. Stage the file to commit: git add project/.gitignore
    5. Commit: git commit -m "message".
    6. Push your change to github.

提交回复
热议问题