Git clone with app password

User
git clone by app password
Assistant
Got it 👍 — you want to clone a Git repo using an **app password** (commonly used with Bitbucket or GitHub when 2FA is enabled).

Here’s the format you should use:

### 1. For HTTPS clone with **username + app password**

git clone https://<username>@bitbucket.org/<workspace>/<repo>.git

👉 When it asks for a password, paste your **app password** instead of your normal password.

### 2. Inline with app password (less secure, but works)

git clone https://<username>:<app_password>@bitbucket.org/<workspace>/<repo>.git

Example:

git clone https://neeraj.tiwari:abcd1234app@bitbucket.org/myteam/myproject.git

⚠️ Note: If your app password has **special characters** (`@`, `#`, `!`, etc.), you need to URL-encode them.
E.g. `#` → `%23`, `@` → `%40`.

### 3. GitHub (same logic)

git clone https://<username>@github.com/<org>/<repo>.git

When prompted for a password → use your **GitHub personal access token (PAT)**.

Do you want me to give you a **ready-to-use example command** if you share whether it’s **GitHub or Bitbucket** and your repo URL?

User
we have github
Assistant
Perfect 👌 If you’re using **GitHub** with 2FA enabled, you can’t use your normal password anymore — you need to use a **Personal Access Token (PAT)** (works the same way as an "app password").

Here’s how you can clone:

### 1. Generate a Personal Access Token
1. Go to [GitHub → Settings → Developer settings → Personal Access Tokens](https://github.com/settings/tokens).
2. Create a new **classic token** (or **fine-grained token**).
– Give it scopes like:
– `repo` → for private repos
– `read:packages` if you need package access
3. Copy the token (treat it like a password).

### 2. Clone using the token

#### Option A: Enter token when prompted

git clone https://github.com/<username>/<repo>.git

👉 When it asks for password, paste the **token** instead of your GitHub password.

#### Option B: Inline (not recommended for shared machines)

git clone https://<username>:<token>@github.com/<username>/<repo>.git

Example:

git clone https://neerajtiwari:ghp_abcd1234EXAMPLETOKEN@github.com/myorg/myrepo.git

⚠️ If the token has special characters, you may need to **URL-encode** them.

✅ That’s it! Once cloned, Git will cache the token (unless you disable credential helper).

👉 Do you want me to also show you how to **store the token in Git credentials** so you don’t have to paste it every time?

Leave a Comment

Your email address will not be published. Required fields are marked *