Tim
Tim

Reputation: 99428

Different `.gitignore` for different remote repositories?

I want to ignore different files when pusshing from my local repository to different remote repositories. But there is only one .gitignore file in my local repository. What should I do?

Upvotes: 8

Views: 3088

Answers (2)

Mykola Gurov
Mykola Gurov

Reputation: 8695

.gitignore is effective only against the working directory, thus will not be applicable after a commit has been made. And you cannot push the same history differently to different remotes. So the answer is no, you can't unless you follow the advice of @h0m3 and use different branches (thus split the history).

Upvotes: 1

h0m3
h0m3

Reputation: 104

I think that branching is the best option in your case. Then you can just add the ignored files to a specific branch and upload that branch to the specific repository.

Although git is not mean to be used like that, since .gitignore is just a list of patterns to be ignored in the current branch, tecnically, shouldn't be different .gitignores in the same branch.

Here is a similar situation to yours and how branching can solve this problem.

Upvotes: 4

Related Questions