Clone Bitbucket with App Password
March 19, 2025 · AI Conversations
### 1. **Create an App Password in Bitbucket**
– Log in to your Bitbucket account.
– Click on your profile picture (bottom left) → **Personal settings**.
– In the left menu, go to **App passwords** (under Access management).
– Click **Create app password**.
– Set a **label** for the app password (e.g., `Git Access`).
– Under **Permissions**, enable:
– **Repository** → `Read` & `Write`
– **Pull Requests** → `Read`
– Click **Create**, and **copy the generated password** (you won't see it again).
### 2. **Use the App Password for Cloning**
Instead of using your Bitbucket password, use your **app password** when cloning:
git clone https://YOUR_BITBUCKET_USERNAME@bitbucket.org/YOUR_WORKSPACE/REPO_NAME.git
When prompted for a password, **paste the app password**.
### 3. **Cache Credentials (Optional)**
If you don’t want to enter the app password each time, configure Git to store credentials:
git config --global credential.helper store
After running this, the first time you enter your credentials, they will be stored for future Git operations.
### 4. **Alternatively, Store Credentials in `~/.git-credentials`**
You can store your credentials in a file for automatic authentication:
git config --global credential.helper 'store --file ~/.git-credentials'
Then, save the credentials in `~/.git-credentials`:
https://YOUR_BITBUCKET_USERNAME:YOUR_APP_PASSWORD@bitbucket.org
This method allows Git to automatically authenticate without prompting for a password.
### 5. **Test Pull and Push**
Run:
git pull
git push
If set up correctly, it won’t ask for a password.
Now, you can work with your Bitbucket repository seamlessly without entering your password for every operation. 🚀
where to use app password above
### **Cloning Using App Password (Manual Entry)**
Run:
git clone https://dailymediain@bitbucket.org/openeratech/frontend.git
When prompted for a password, **enter your Bitbucket app password** instead of your Bitbucket account password.
—
### **Cloning Without Entering Password Every Time**
To avoid entering the app password each time, follow one of these methods:
#### **1. Using Credential Storage (Recommended)**
Configure Git to store credentials:
git config --global credential.helper store
Then, run:
git clone https://dailymediain@bitbucket.org/openeratech/frontend.git
After entering your app password **once**, it will be cached for future use.
—
#### **2. Storing Credentials in `~/.git-credentials` (Less Secure)**
Run:
git config --global credential.helper 'store --file ~/.git-credentials'
Then, save your credentials in the `~/.git-credentials` file:
https://dailymediain:APP_PASSWORD@bitbucket.org
Replace `APP_PASSWORD` with your actual Bitbucket **app password**.
—
#### **3. Using SSH Instead of HTTPS (Best for Security)**
Instead of using an app password, you can set up SSH authentication:
– Generate an SSH key:
ssh-keygen -t rsa -b 4096 -C "your-email@example.com"
– Add the key to Bitbucket under **Personal settings → SSH keys**.
– Use the SSH URL instead:
git clone git@bitbucket.org:openeratech/frontend.git
—
#### **4. Using `.netrc` (For CI/CD or Automation)**
Create a `~/.netrc` file and store credentials:
machine bitbucket.org
login dailymediain
password APP_PASSWORD
Set correct permissions:
chmod 600 ~/.netrc
Now Git will automatically authenticate without prompting.
—
### **Which Method Should You Use?**
– If you're cloning on your local machine: **Use credential storage (`git config –global credential.helper store`)**.
– If you're setting up a CI/CD pipeline: **Use `.netrc`**.
– If you prefer a more secure method: **Set up SSH authentication**.
Let me know if you need further assistance! 🚀