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
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.