Himmators
Himmators

Reputation: 15026

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

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 repository. How do I do this?

Upvotes: 4

Views: 3513

Answers (1)

Bartosz
Bartosz

Reputation: 6193

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.

Upvotes: 3

Related Questions