Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

167
Visualizações
Mount git branches in a container

I have a git repository with 2 distinct branches, for instance master and foo:

mkdir test && cd test
git init
echo master > master
git add . && git commit -m "init master"
git checkout -b foo
rm master
echo foo > foo
git add . && git commit -m "init foo"

Now I want to mount master and foo in a container as separated volumes, in order to have this architecture in my container:

.
├── foo
│   └── foo
└── master
    └── master

Is it possible?

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

You could use two git worktrees. Worktrees allow you to have more than one branch checked out at different paths.

$ git status
On branch master
…
$ git worktree add ../develop
Preparing ../develop (identifier develop)
HEAD is now at fbbbc04 netcat6 for gnks
$ git -C ../develop status
On branch develop
nothing to commit, working tree clean

Then mount those directories in your container.

about 4 years ago · Santiago Trujillo Relatório

0

You'd need two clones, one with master checked out and one with foo checked out. They can be shallow clones to save space.

git clone file:///full/path/to/the/repo --depth 1 --branch master master
git clone file:///full/path/to/the/repo --depth 1 --branch foo foo

It might make more sense to just have one clone inside the VM and use it like a normal git clone.

about 4 years ago · Santiago Trujillo Relatório

0

I don't believe you can mount git branches as-is. However, if Schern answer isn't enough (you may want to have a common repository and two working directories) I'd recommand looking into this: https://git-scm.com/docs/git-worktree

That way, both directories will share the same .git directory (one will be an instruction for git to look in the other)

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda