Giter VIP home page Giter VIP logo

manage_repos's Introduction

Manage Git Repos

Typically, when I am working on personal projects (think lots of different jupyter notebooks) my work flow involves a number of repos for different parts of a project. Typically I am the only one working on the repositories across different machines. I wrote this script to help me out. The script will allow me to iterate recursively through a file path and find all valid repos. I can then do batch operations such as stage all unstaged changes. Commit any stage changes and push them to remote repositories. It is really quite nice. Typically I'll have private repos stored on my home computers and have remote repos on my laptops or other systems.

I simply work on master. I don't see a reason to do anything different as I am not generally collaborating with anyone on these projects. In order to push my changes to my remote repositories I need to create a branch to push because it won't let me push to the remote repo on master.

So master contains the latest changes. When I work on another computer I work on a branch named after that computer. When I get back to my main system I merge all the branches into master. It is really quite simple. The complexity comes with the shear number of repos to manage. This is where the script comes in.

The script, given a path will recursively search for git repos. The operation will be applied to each repository in succession. You can:

  • list - This will simply list the names of the repos that were found.
  • status - This will list the status of each repository.
  • checkout - This will create a new branch and checkout it for each repository. Typically the branch is named after the computer I am currently working on.
  • add - Stage any new files to the current branch.
  • commit - Commit any staged changes to the current branch.
  • push - Push the staged changes to the remote repository.
  • changes_to_remote - This is a group method that creates the new branch, adds any changes, commits the changes and pushes in one go for each repository.
$ python3 manage_repos.py --help
usage: manage_repos.py [-h] [-l] [-s] [--checkout BRANCH NAME] [--add]
                       [--commit MESSAGE] [--push] [--changes_to_remote]
                       path

Manage Git Repositories.

positional arguments:
  path                  The root path where the repos are located.

optional arguments:
  -h, --help            show this help message and exit
  -l, --list            List all of the repositories recursively from the
                        root.
  -s, --status          List the status of the repositories.
  --checkout BRANCH NAME
                        The name of the branch in the repo to checkout. It
                        will be created if it doesn't exist.
  --add                 Add new files to the stage of the current branch.
  --commit MESSAGE      Commit the files to the active branch with the commit
                        message.
  --push                Push the changes to remote, creating a tracking branch
                        if required.
  --changes_to_remote   Take the changes in a repo, create a branch, commit
                        them and push to remote creating a tracking branch if
                        necessary. Required: --checkout BRANCH NAME and
                        --commit MESSAGE

manage_repos's People

Contributors

troywilliams3687 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.