0

Context

I have 2 git repositories (gitone and gittwo) in one directory.

For setting them up, I followed these steps.

So now, I have two aliases:

alias gitone='git --git-dir=.gitone'
alias gittwo='git --git-dir=.gittwo'

Problem

I want to ignore distinct files in each repo.

Solution?

I created a .gitignore:

# Ignore everything ...
*

# ... except ...
!/.gitignore
!/gittwo-ignore.txt
!*.sql

# ... from all directories and subdirectories
!*/

I want .gitignore to work for gitone, but not for gittwo. For this, I created gittwo-ignore.txt:

# Ignore everything (including gitignore)...
*

# ... except ...
!*.ipynb
!/gittwo-ignore.txt

# ... from all directories and subdirectories
!*/

and I added it to the core.excludesfile:

gittwo config --global core.excludesfile ~/gittwo-ignore.txt
gittwo rm -r --cached .
gittwo add .
gittwo commit -m 'Hopefully this now works'
gittwo push origin master

I was hoping that with gittwo-ignore.txt, gittwo would ignore .gitignore and only take into account the rules from gittwo-ignore.txt.

Unfortunately, my repo gittwo still only contains .sql files (so only takes into account the ignore rules from .gitignore).

How can I fix this?

ludmilaex
  • 97
  • 1
  • 5
  • 1
    What about removing .gitignore altogether and setting a custom exclude file for gitone as well? – Papooch May 07 '20 at 10:45
  • @Papooch short story, gitone is meant to be cloned by my coworkers. They need to see the .gitignore file in the git repo. – ludmilaex May 07 '20 at 12:18
  • Maybe this could help, then: https://stackoverflow.com/questions/2994612/is-there-a-way-to-tell-git-status-to-ignore-the-effects-of-gitignore-files Another think I thought of is, instead of keeping both git repos in a single folder, you could keep them separate and symlink content from both to a separate directory, see: https://stackoverflow.com/questions/423320/can-i-symlink-multiple-directories-into-one or https://www.linuxquestions.org/questions/linux-general-1/symlink-two-dirs-into-one-327587/ – Papooch May 07 '20 at 12:38

0 Answers0