When attempting to clone a repository across my local network between Ubuntu machines, I encountered persistent "does not appear to be a git repository" errors, despite:
- Successful ping and network access
- Working Windows SMB access (using
//192.168.100.18/repo/intranet.git
) - Multiple protocol attempts (file://, smb://, raw paths)
Ubuntu's default Git installation doesn't automatically handle Windows-style SMB paths like //server/share
. The key issues:
# These WON'T work directly in Ubuntu:
git clone //192.168.100.18/repo/repository.git
git clone smb://pc-name/repo/repository.git
Method 1: Mount the Share First
The most reliable approach is mounting the network share before Git operations:
# Create mount point
sudo mkdir /mnt/git_repo
# Mount with credentials
sudo mount -t cifs //192.168.100.18/repo /mnt/git_repo -o username=user,password=pass
# Now clone normally
git clone /mnt/git_repo/repository.git
Method 2: Use Proper file:// Protocol Syntax
The correct file:// format requires mounted paths:
# If mounted at /media/share
git clone file:///media/share/repo/repository.git
Note: Triple slashes (file:///) are correct for local paths after mount.
Method 3: SSH Alternative (Recommended)
For frequent access, setup SSH on the remote machine:
git clone user@192.168.100.18:/path/to/repo.git
- Permissions: Ensure the mounted share has execute permissions (
chmod +x
) - Credential caching: Use
git config --global credential.helper store
- Protocol verification: Test with
git ls-remote file:///mounted/path
before cloning
Here's a tested sequence that works reliably:
# Install CIFS utils if needed
sudo apt install cifs-utils
# Create credentials file
echo "username=myuser" > ~/.smbcredentials
echo "password=mypass" >> ~/.smbcredentials
chmod 600 ~/.smbcredentials
# Add to fstab for persistence
echo "//192.168.100.18/repo /mnt/git_repo cifs credentials=/home/user/.smbcredentials,uid=1000 0 0" | sudo tee -a /etc/fstab
# Mount and clone
sudo mount -a
git clone /mnt/git_repo/repository.git
This approach handles authentication, mounting, and Git operations in a maintainable way.
When attempting to clone repositories across a local network in Ubuntu, several factors come into play that differ from Windows environments. The core requirements are:
- Proper fileshare mounting
- Correct protocol specification
- Authentication handling
- Repository path formatting
The error messages you're seeing typically indicate one of these underlying issues:
# Classic symptoms:
fatal: '//path/repo.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Before using git commands, ensure proper fileshare mounting:
sudo mkdir -p /mnt/git-share
sudo mount -t cifs //192.168.100.18/repo /mnt/git-share -o username=youruser,password=yourpass,uid=$(id -u),gid=$(id -g)
Try these alternative cloning methods after mounting:
# Using direct filesystem path
git clone /mnt/git-share/repository.git
# Using SSH (if configured)
git clone ssh://user@192.168.100.18/repo/repository.git
# Using git protocol with proper escaping
git clone file://192.168.100.18/repo/repository.git
For password-protected shares, consider these approaches:
# Store credentials in .netrc
machine 192.168.100.18
login yourusername
password yourpassword
# Or use credential helper
git config --global credential.helper store
The key differences in path interpretation:
- Windows accepts forward and backward slashes
- Ubuntu requires proper URI encoding
- Network paths need proper protocol prefix
For frequent network access, consider running git daemon:
# On the host machine:
git daemon --base-path=/repo --export-all --enable=receive-pack
Before concluding the repository is inaccessible:
# Check basic connectivity
smbclient -L //192.168.100.18 -U username
# Verify git repository integrity
git fsck --full