Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda