How to stop tracking and ignore changes to a file in Git?

前端 未结 20 1737
梦谈多话
梦谈多话 2020-11-21 07:17

I have cloned a project that includes some .csproj files. I don\'t need/like my local csproj files being tracked by Git (or being brought up when c

20条回答
  •  北恋
    北恋 (楼主)
    2020-11-21 07:55

    Forgot your .gitignore?

    If you have the entire project locally but forgot to add you git ignore and are now tracking some unnecessary files use this command to remove everything

    git rm --cached -r .
    

    make sure you are at the root of the project.

    Then you can do the usual

    Add

    git add .
    

    Commit

    git commit -m 'removed all and added with git ignore'
    

    Push

    git push origin master
    

    Conclusion

    Hope this helps out people who have to make changes to their .gitignore or forgot it all together.

    • It removes the entire cache
    • Looks at your .gitignore
    • Adds the files you want to track
    • Pushes to your repo

提交回复
热议问题