This repository contains a set of Bash scripts designed for managing Git repositories. Each script performs specific tasks related to Git operations.
s.sh
: Displays the status of a Git repository.check.sh
: Checks out a specified branch in the repository.base.sh
: Commits and pushes changes to the repository.config.sh
: Similar tobase.sh
but modifies the commit message.reset.sh
: Resets a specified number of commits on a branch.gc.sh
: Executes specified Git commands in the repository and handles outputs efficiently.
- Prerequisites: Ensure Git is installed on your system.
- File Creation:
- Create a file named
repo_details.txt
containing the repository path (first line) and branch name (second line). - For
base.sh
andconfig.sh
, create a file namedcommit_message.txt
for commit messages.
- Create a file named
- Make Scripts Executable: Run the following command for each script:
chmod +x <script_name>.sh
Each script can be executed with specific command-line options. Use the -h
option to display help messages for each script.
./s.sh -p <repository_path>
- To use the default path from
repo_details.txt
:
./s.sh
- To see the help message:
./s.sh -h
- Checks if Git is installed.
- Reads the repository path from
repo_details.txt
or accepts it as a command-line argument. - Navigates to the specified Git repository and runs
git status
.
- Displays an error message if Git is not installed.
- Checks if the
repo_details.txt
file exists and reads from it. - Validates the existence of the specified repository path.
./check.sh -b <branch_name>
- To specify a repository path:
./check.sh -p <repository_path> -b <branch_name>
- To see the help message:
./check.sh -h
- Validates if Git is installed.
- Reads repository details from
repo_details.txt
or command-line arguments. - Changes to the specified repository directory and checks out the specified branch.
- Displays an error if Git is not installed.
- Checks for the existence of
repo_details.txt
. - Verifies that the specified branch exists before checking it out.
./base.sh -m "<commit_message>"
- To use the commit message from
commit_message.txt
:
./base.sh
- To see the help message:
./base.sh -h
- Checks if Git is installed.
- Reads repository details and commit messages from respective text files or command-line arguments.
- Adds all files to the Git index, commits them, and pushes to the specified branch.
- Handles missing files for repository details or commit messages.
- Validates the repository path and checks for successful Git operations.
./config.sh -m "<commit_message>"
- To use the default message from
commit_message.txt
:
./config.sh
- To see the help message:
./config.sh -h
- Similar to
base.sh
but appends_config
to the commit message. - Allows users to commit changes and push to the specified branch.
- Handles missing files and invalid Git operations.
- Displays error messages for common issues.
./reset.sh -n <num_commits>
- To specify the branch name and repository path:
./reset.sh -p <repository_path> -b <branch_name> -n <num_commits>
- To see the help message:
./reset.sh -h
- Resets the specified number of commits on a given branch.
- Supports committing ranges.
- Forces the push to the remote repository after resetting.
- Checks for valid commit ranges and handles invalid inputs gracefully.
- Displays errors for Git installation and directory access issues.
Certainly! Here’s the gc.sh
documentation formatted in the same style as the previous scripts:
./gc.sh --git <command1> [<command2> ...]
- To specify a repository path:
./gc.sh --git status --git log -p <repository_path>
- To see the help message:
./gc.sh -h
- Checks if Git is installed on the system.
- Reads the repository path from
repo_details.txt
or accepts it as a command-line argument. - Supports executing multiple Git commands in sequence, providing feedback for each command executed.
- If no commands are provided, defaults to executing
git status
. - Automatically disables the pager for lengthy outputs (e.g.,
git log
) to prevent issues with viewing large logs.
- Displays an error message if Git is not installed.
- Checks if the
repo_details.txt
file exists and reads the repository path from it if not provided. - Validates the existence of the specified repository path before executing commands.
- Handles invalid Git commands gracefully and displays appropriate error messages.