﻿---
title: Git for Android
date: 2024-03-08
excerpt: 安卓平台Git客户端的使用
tags:
  - Git
  - Android
  - GitHub
cover: https://assets.vluv.space/cover/ToolChain/gitForAndroid.webp
---

## DownLoad

1. 在 F-Droid 中搜索`Mgit`，下载并安装。(Play 商店中也有,但功能不能正常使用)
2. 在[GitHub](https://github.com/maks/MGit)仓库选择合适的版本下载

## Quick Start

### Clone a remote repository

- Click on the `+` icon to add a new repository
- Enter remote URL [see URL format below](#url-format)
- Enter local repository name - note that this is not the full path, as MGit stores all repositories in the same local directory (can be changed in MGit settings)
- Click the Clone button
- If required, you will be prompted for credentials to connect to the remote repo. MGit will download the repository (all branches) to your device

### Create a local repository

- Click on the + icon to add a new repository
- Click on Init Local to create a local repository
- Enter the name for this repository when prompted
- A local empty repo will be created

### URL format

**SSH URLs**
SSH running on standard port (22): `ssh://username@server_name/path/to/repo`
SSH running on non-standard port: `ssh://username@server_name:port/path/to/repo`
username is needed - by default, MGit tries to connect as root.
**HTTP(S) URLs**
HTTP(S) URL: `https://server_name/path/to/repo`

### SSH

**MGit App**
`Settings -> SSH Keys -> + icon -> input NewFileName -> Generate Key -> Open File and Copy the content`
**GitHub**
[Settings/keys](https://github.com/settings/keys)
New SSH Key -> input Title -> Paste the content
