Skip to content

A powerful Git automation script that simplifies backing up changes, syncing the codebase, and committing/pushing updates.

License

Notifications You must be signed in to change notification settings

prajyotzankar/Git-Automation-Script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

🚀 Git Automation Script

This script automates various Git operations including backing up changed files, syncing the codebase with a remote repository, and committing and pushing changes to the current branch. It is designed to streamline the development process by handling repetitive tasks efficiently.

Clone or Download

git clone https://github.com/prajyotzankar/Git-Automation-Script.git

Usage

  1. Navigate to your local Git repository:

    cd /path/to/your/repository
  2. Make the script executable:

    chmod +x path/to/your/back_up_sync_add_commit_push.sh
  3. Run the script:

    ./path/to/your/back_up_sync_add_commit_push.sh

Script Workflow

  1. Set Destination Folder:

    • Determines the destination folder based on the current branch.
    • Creates the folder if it doesn't exist.
  2. Backup Changed Files:

    • Identifies modified and untracked files with the extensions .jsp, .xsd, and .java.
    • Copies these files to the destination folder.
  3. Sync Codebase with Remote:

    • Clears any existing stash.
    • Stashes current changes.
    • Switches to the main branch and pulls the latest changes.
    • Switches back to the current branch and rebases it with the main branch.
    • Applies the stashed changes.
  4. Add, Commit, and Push Changes:

    • Displays the files to be added.
    • Prompts for confirmation before staging the files.
    • Prompts for a commit message and commits the changes.
    • Pushes the changes to the current branch.

Customization

  • Main Branch: The script uses MAIN_BRANCH as the main branch. You can change this by modifying the main_branch variable.
  • File Extensions: The script currently backs up files with .jsp, .xsd, and .java extensions. You can add or remove extensions by updating the regular expression in the get_changed_files_and_backup function.

Project Status

The script is functional and can be customized based on specific project requirements.

Example Output

When you run the script, you will see prompts and output similar to the following:

You are on the branch 'feature_branch'. Is this the correct feature branch? (y/n): y
feature_branch Folder Created Successfully

Copied example.jsp to D:\Study\GitScript\tasks\feature_branch
Copy process completed.

Clearing Git stash...
Creating a new Git stash...
Switching to MAIN_BRANCH...
Pulling from MAIN_BRANCH...
Switching to feature_branch...
Rebasing with MAIN_BRANCH...
Applying the stashed changes

Code base Sync completed.

Files that will be added:
example.jsp

Do you want to proceed with adding these files? (y/n): y
Files staged:
example.jsp

Do you want to proceed with commit? (y/n): y
Enter the commit message (will be appended to 'feature_branch: '): Added example.jsp

Git add and commit completed successfully.

Do you want to proceed with pushing these changes to 'feature_branch'? (y/n): y
Git add, commit, and push completed successfully.

BUGs or comments

Create new Issues (preferred)

Email Me: [email protected] (welcome, say hi)

Author

Prajyot Zankar

License

License: MIT

About

A powerful Git automation script that simplifies backing up changes, syncing the codebase, and committing/pushing updates.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages