Sign inSign up

softjpn/git

By softjpn

•Updated almost 2 years ago

A minimal Docker image containing the latest Git, optimized for managing multiple GitHub accounts.

Image
Integration & delivery
0

409

softjpn/git repository overview

⁠Introduction

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.

⁠Features
  1. Small Image Size – Using Alpine Linux reduces the final image size significantly.
  2. Latest Git – Installs the latest Git version from the Alpine packages (which are frequently updated).
  3. Simple Volume Mount – Easily mount your current directory into /app in the container.
  4. (Optional) Per-Folder Configuration – You can use separate .gitconfig files or local .git/config to manage different GitHub account settings per folder.
⁠Pull Image
docker pull softjpn/git
⁠Basic Usage Examples

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
⁠More Git Commands

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>

  • Clone a remote repository
    docker run --rm -it -v "$PWD:/app" softjpn/git clone https://github.com/user/repo.git
    
  • Check current branch and commits
    docker run --rm -it -v "$PWD:/app" softjpn/git branch
    docker run --rm -it -v "$PWD:/app" softjpn/git log --oneline --graph
    
  • Switch branches
    docker run --rm -it -v "$PWD:/app" softjpn/git checkout <branch-name>
    
  • Create a new branch
    docker run --rm -it -v "$PWD:/app" softjpn/git checkout -b <new-branch-name>
    
  • Pull latest changes from remote
    docker run --rm -it -v "$PWD:/app" softjpn/git pull
    
  • Merge branches
    # 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>
    
  • Rebase branches
    docker run --rm -it -v "$PWD:/app" softjpn/git checkout main
    docker run --rm -it -v "$PWD:/app" softjpn/git rebase <feature-branch>
    
  • Stash changes
    docker run --rm -it -v "$PWD:/app" softjpn/git stash
    docker run --rm -it -v "$PWD:/app" softjpn/git stash pop
    
  • Tagging
    # 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
    
  • Configure user info
    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]"
    
⁠Tips for Per-Folder GitHub Account Settings

You can maintain different Git configurations per project by storing them in each repository’s .git/config. For instance:

  1. Create or edit .git/config in your local repo.
  2. Add or modify user info, e.g.:
    [user]
        name = "MyProjectName"
        email = "[email protected]"
    
  3. Whenever you run the Docker container against that folder, it will respect these settings.

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

⁠Enjoy Git in a Container!

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.

Tag summary

Content type

Image

Digest

sha256:25e1073de…

Size

9.9 MB

Last updated

almost 2 years ago

docker pull softjpn/git