Git Automation Tool is a Python-based tool designed to simplify the management of Git and GitHub repositories automatically. This tool is highly beneficial for developers who frequently work with Git repositories, as it saves time on manual tasks such as GitHub CLI installation, authentication, repository creation, and commit/push management.
-
GitHub CLI Installation
- Checks if GitHub CLI (gh) is installed.
- Automatically installs GitHub CLI if not available (supports Linux, macOS, Windows, and Termux).
-
Authentication to GitHub
- Authenticates using a Personal Access Token (PAT) for secure access.
-
GitHub Repository Creation
- Creates a new GitHub repository with customizable descriptions.
-
Local Repository Initialization
- Initializes a local directory as a Git repository.
- Adds a remote URL to the created GitHub repository.
-
Automatic Commit and Push
- Adds all files to the staging area.
- Creates an initial commit and pushes it to the main branch.
-
Install Python
Ensure Python 2.7 is installed. You can download it from the official website: Python. -
Install Required Module
Run the command:pip install requests
. -
Add Your GitHub Token
Save your GitHub Personal Access Token (PAT) in a file namedtoken.txt
in the same directory as the tool. -
Run the Tool
Execute the script using the command:python git_push.py
. -
Follow the Instructions
Complete the setup and automation steps via the terminal.
-
Log in to Your GitHub Account
Go to GitHub and log in. -
Access Developer Settings
- Click your profile icon in the top-right corner.
- Select Settings > Developer settings > Personal access tokens > Tokens (classic).
-
Generate a New Token
- Click Generate new token > Generate new token (classic).
- Provide a description for your token, e.g., "Git Automation Tool".
- Choose the token duration (e.g., 30 or 60 days).
-
Select Permissions
- Enable the following permissions:
- repo: Access to private and public repositories.
- workflow: Access GitHub Actions (if needed).
- delete_repo (optional): Allow repository deletion.
- Click Generate token.
- Enable the following permissions:
-
Save the Token
- Copy the generated token immediately, as it won’t be shown again.
- Save it in the
token.txt
file.