A Guide to Setting up Private Repositories on GitHub for CFN and Python Projects
To set up a GitHub account and create private repositories to push CFN (CloudFormation) code and Python code, follow these steps:
Create a GitHub Account:
Go to github.com and click on "Sign up" to create a new account.
Follow the instructions to set up your account with a username, email, and password.
Subscribe for a GitHub Plan:
Go to github.com/pricing and choose a plan that fits your needs. If you want to keep your repositories private, you will need to select a paid plan (e.g., GitHub Pro or GitHub Team).
Create Private Repositories:
Click "Create New repository."
Provide a name for your repository and select "Private" under the "Visibility" options.
- Initialize the repository with a README file if you wish (optional).
- Click on "Create repository" to create the private repository
Import Existing Repositories (Optional):
If you have existing code in other repositories that you want to import, follow these steps to import them into your private GitHub repository:
Click on the "+" sign in the top-right corner and select "Import repository."
Provide the URL of the existing repository and choose the destination (your private repository) to import the code.
example:
https://github.com/Microsoft/python-sample-vscode-flask-tutorial
-
Repository Imported successfully
Install Git:
To install Git on local machine. we can download it from git-scm.com/downloads and follow the installation instructions for your operating system.
Set up Git Configurations:
- Open a terminal or command prompt and configure your Git user information with appropriate permissions to access the GitHub repository
Clone Your Private Repository:
On your GitHub account, navigate to the private repository you created earlier.
Click on the green "Code" button and copy the repository URL.
In your terminal or command prompt, navigate to the directory where you want to clone the repository and run:
git clone git@github.com:eddzaa/azurepy.git
Add and Push Your CFN and Python Code:
After successfully cloning the private repository using the SSH URL, follow these steps:
Navigate to the Cloned Repository Directory:
- Use the
cd
command to navigate to the directory where you cloned the repository. For example:
cd /path/to/azurepy
Copy Your CloudFormation (CFN) and Python Code:
Locate the CloudFormation (CFN) and Python code that you want to add to the repository on your local machine.
Example CloudFormation Template (my_cfn_template.yml):
AWSTemplateFormatVersion: '2010-09-09' Description: Sample CloudFormation Template Resources: MyEC2Instance: Type: AWS::EC2::Instance Properties: InstanceType: t2.micro ImageId: ami-0c55b159cbfafe1f0 # Replace with a valid AMI ID for your region
Example Python Script (my_python_script.py):
def add_numbers(a, b): return a + b result = add_numbers(3, 5) print("The sum of 3 and 5 is:", result)
Copy these files or directories to the local repository directory (
/path/to/azurepy
) that you cloned in the previous step.cd /path/to/azurepy
Use the following commands to add, commit, and push your code to the private repository:
git add .
git commit -m "Initial commit" # Add a meaningful commit message
git push origin main # Assuming the default branch is 'main'
Now your CFN code and Python code are safely stored in your private GitHub repository. Remember to use git push
every time you make changes to your code to keep the repository up to date.
Thank you ! I hope the guide on setting up private repositories for CloudFormation (CFN) and Python code on GitHub helpful. By following the steps outlined, we can securely manage and collaborate on projects with ease.
Happy coding, and best of luck with your GitHub repositories and coding endeavors! Until next time! ๐