Is there an exclude file-equivalent for pushing in git?

前端 未结 1 1644
梦如初夏
梦如初夏 2021-01-19 17:20

I am using the exclude file to avoid my local settings from being overwritten when I pull a repository. I would like the same files to not be pushed when I push to the main

相关标签:
1条回答
  • 2021-01-19 18:03

    If a file is committed to your local repository (you did git add <file> and git commit) then if you push this commit to any other repository that file will be pushed too. You can push only whole commits, not individual files.

    If you don't want to push this file, you have to first remove it, make a new commit with this file removed, and add it to .gitignore to avoid committing it again. So steps like this:

    git rm yourfile
    git commit -m 'Removing yourfile'
    echo yourfile >> .gitignore
    

    And you are done.

    0 讨论(0)
提交回复
热议问题