R
R
Romi2021-08-29 09:43:53
git
Romi, 2021-08-29 09:43:53

Is it possible to somehow have a file in the local repository, but at the same time so that it does not get pushed to the remote one?

I want to have .env in the local repository - for example, to use different bases in different branches.

But at the same time, I don't want .env to be pushed to github.

Is this possible in Git?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Kuznetsov, 2021-09-02
@romicohen

Git pushes not files, but branches with commits, so the external repository will contain an exact copy of the local data. The repository is essentially one, and it is distributed. This is how Git works. There is no difference local or external.
Do not store configs in the repository at all if it goes public!
So the correct answer to the question is no.
But you can unpack (checkout) different branches into different directories (worktree). And for everyone you can make the necessary settings. So you get what you want and passwords do not have to shine in a public external repository.

A
Alexander Karabanov, 2021-08-29
@karabanov

Add it to .gitignore

L
Lynn "Coffee Man", 2021-08-29
@Lynn

Not

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question