A minimal Docker image containing the latest Git, optimized for managing multiple GitHub accounts.
409
This repository provides a minimal Docker image based on Alpine Linux, with the latest version of git installed. The goal is to keep the image size as small as possible while ensuring users can conveniently work with Git in any folder on their local machine.
/app in the container..gitconfig files or local .git/config to manage different GitHub account settings per folder.docker pull softjpn/git
Mount your local directory ($PWD) to /app in the container and execute Git commands as you normally would:
# Check status
docker run --rm -it -v "$PWD:/app" softjpn/git status
# Stage all changes
docker run --rm -it -v "$PWD:/app" softjpn/git add -A .
# Commit
docker run --rm -it -v "$PWD:/app" softjpn/git commit -m "Your commit message"
# Push to a remote branch
docker run --rm -it -v "$PWD:/app" softjpn/git push origin main
Below are a few more commonly used Git commands. Simply prefix them with the same Docker run pattern, for example:
docker run --rm -it -v "$PWD:/app" softjpn/git <command>
docker run --rm -it -v "$PWD:/app" softjpn/git clone https://github.com/user/repo.git
docker run --rm -it -v "$PWD:/app" softjpn/git branch
docker run --rm -it -v "$PWD:/app" softjpn/git log --oneline --graph
docker run --rm -it -v "$PWD:/app" softjpn/git checkout <branch-name>
docker run --rm -it -v "$PWD:/app" softjpn/git checkout -b <new-branch-name>
docker run --rm -it -v "$PWD:/app" softjpn/git pull
# First, checkout the branch you want to merge into
docker run --rm -it -v "$PWD:/app" softjpn/git checkout main
# Then merge
docker run --rm -it -v "$PWD:/app" softjpn/git merge <other-branch>
docker run --rm -it -v "$PWD:/app" softjpn/git checkout main
docker run --rm -it -v "$PWD:/app" softjpn/git rebase <feature-branch>
docker run --rm -it -v "$PWD:/app" softjpn/git stash
docker run --rm -it -v "$PWD:/app" softjpn/git stash pop
# Create a new tag
docker run --rm -it -v "$PWD:/app" softjpn/git tag v1.0.0
# Push tags
docker run --rm -it -v "$PWD:/app" softjpn/git push --tags
docker run --rm -it -v "$PWD:/app" softjpn/git config user.name "Your Name"
docker run --rm -it -v "$PWD:/app" softjpn/git config user.email "[email protected]"
You can maintain different Git configurations per project by storing them in each repository’s .git/config. For instance:
.git/config in your local repo.[user]
name = "MyProjectName"
email = "[email protected]"
You can also maintain custom .gitconfig files outside of the .git folder and mount them into the container. For example:
docker run --rm -it \
-v "$PWD:/app" \
-v "$PWD/.my_gitconfig:/root/.gitconfig" \
softjpn/git status
With softjpn/git, you no longer need a local Git installation. Keep your environment clean and simply run Docker containers for all your Git needs. If you have any issues or suggestions, feel free to open an issue on the GitHub repository for this image.
Content type
Image
Digest
sha256:25e1073de…
Size
9.9 MB
Last updated
almost 2 years ago
docker pull softjpn/git