Friday, February 8, 2019

Connect EC2 instance to Git Repo - How to connect EC2 instance to BitBucket

Let us see steps for connecting an EC2 instance to Git repo such as BitBucket.

1. Create SSH keys in EC2 instance first by executing below command:

(no need to give any password)

The above command will create two keys - public key( and private key(is_rsa)

2. Copy public keys from .ssh folder

sudo cat ~/.ssh/

3. Now go to Bitbucket, click on avatar and click on Bitbucket Settings.
 4. Click on Add Key and copy the content of public keys

5. Now click on repo you want to make a code change. Click on Clone and copy the SSH url. Do not select HTTPS Url. The url will be from your repo you created under Clone link.

6. Go to your EC2, perform below command:

git clone <ssh_url_from_bitbucket_repo_you_copied>

7. Click yes to connect

8. Now you will see a folder with reponame created.

9. You can cd into reponame and make some code changes..once you make a code change, you can commit into Bitbucket by entering below comments

10. git add *

11. got commit -m "My first commit" 

12. git push

Now go to Bitbucket refresh you will see the code changes in BitBucket.

No comments:

Post a Comment

How to create Pull Request (PR) templates in Github repository | Creating a pull request template for your GitHub repository

Creating pull request (PR) templates in GitHub can help streamline the process of submitting PRs by providing a predefined structure. Thi...