Docker - Install and use Git in a container just like you do on your host
So, no need to tell it anymore, I'm doing everything in Docker containers even coding (since I'm coding using devcontainers) but ... till now, I was using git
on my host only.
I mean, I need git
on my host because I should be able to clone a repository. But the question is: should I use git from my host except for git clone
? Can I work in my container and from there do actions like a git push
?
My current workflow is: from my host, I'm cloning a repo on my disk then I build Docker image(s), run container(s) and jump in it (like starting my devcontainer). I start too a console in my container to start processes, work on files, ...
From time to time, I push my changes to my versioning system (like Gitlab/GitHub) and here is the point: I need to exit my devcontainer (or use another console), go back to my host and run, from my host, commands like git add . && git commit -m "feat: The great feature I'm working on it" && git push
.
Let's see how to improve this process and be able to run git
commands from inside our container.