1

It may be a vague question, but I can't currently find a good solution in my head.

I have a BookStack application running on a company server. To simplify and for security I have a custom .gitignore file which ignores everything except our custom extensions and .env configuration.

The idea is that developers can add the production repository as remote source in a directory with BookStack along a mocked database to test it securely.

Now, this is fine as long I don't have to fetch from BookStack repository. If I add now BookStack as remote source on the production server it will conflict with the .gitignore on update.

Do you have any advice on how I could solve this problem, other than resolving this conflict with each update?

1
  • 1
    There are several options. Take a look at wokrtree. >Git worktrees allow you to have multiple working directories attached to the same repository. This can be useful to keep your customizations and the upstream code separate. Commented Feb 21 at 18:49

1 Answer 1

1

This is just an idea and a small general guide on what you could do with worktree.

As mentioned, there are several possibilities.

You could also use separate branches for customizations or use an automated custom script etc..

Git Worktree for Clean Separation

With Git Worktree, you can create two separate working directories for the same repository:

  • One for the upstream changes (BookStack).
  • One for your own customizations (Custom Code).

This avoids conflicts and allows you to manage both versions in parallel.

Steps:

  • Clone your repository to the server

  • Add the BookStack repository as an upstream remote

  • Create a new working directory (Worktree) for the upstream branch

  • Work in your main directory on a separate branch

  • Update the upstream worktree with git pull

  • Merge the changes into your custom branch if needed

  • Use .git/info/exclude to ignore files like .env or custom extensions

Upstream changes and your own customizations are separated and can be updated independently of your code.

You can use both versions in parallel without constantly switching branches.

worktree

.git/info/exclude

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.