Giter Club home page Giter Club logo

gitz's Introduction

๐Ÿ—œ gitz - git commands for rapid development ๐Ÿ—œ

This is a collection of seventeen git utilities aimed at people doing rapid development using Git.

Gitz is for two types of users - quality-obsessed individuals who relentlessly manicure their pull requests until every byte is in the right place; and ultra-rapid developers who want to generate large features quickly while taking advantage of continuous integration.

Most of these utilities only exist here, one came from a chat on Reddit and I don't know where one of them came from.

Four of them are written in Bash, the rest use Python 3. They have been tested on Mac OS/X (Darwin) and on Ubuntu, and will likely work on any Unix-like operating system.

How to install

Use pip:

pip3 install gitz

Or simply download this directory and make sure it's in your shell's PATH - gitz has no external dependencies.

Getting help

This page contains a summary and a link to a manual page for each command. From the terminal, use -h flag like this: git new -h or use man like this: man git-new.

When to use gitz

  1. At the start of a session
    • git new safely creates fresh branches from upstream
    • git update for each branch, rebases from upstream and force-pushes
  2. During development
    • git st is a more compact and prettier git status
    • git when shows you when documents were last changed
  3. During rapid development
    • git infer commits files with an automatically generated message - great for committing tiny changes for later rebasing down
  4. While cleaning up a branch for review
    • git permute permutes, squashes or removes commits in the current branch
    • git split split one or more commits, perhaps with the staging area, into many small individual commits, one per file
  5. During repository maintenance
    • git rotate rotates through all branches
    • git copy, git delete, and git rename work on both local and upstream branches
  6. Working with continuous integration
    • git stripe pushes a sequence of commits to individual remote branches where CI can find and test them

The movie

The whole gitz movie

The gitz commands

Safe commands

Informational commands that don't change your repository

git gitz
Print information about the gitz git commands
git go
Open a browser page for the current repo
git infer

Commit changes with an automatically generated message

(from https://github.com/moondewio/git-infer)

git multi-pick
Cherry-pick multiple commits, with an optional squash
git new
Create and push new branches
git rot
Rotate through branches in a Git repository
git st
Colorful, compact git status
git stripe
Push a sequence of commit IDs to a remote repository
git when

For each file, show the most recent commit that changed it.

Dotfiles are ignored by default.

Dangerous commands that delete, rename or overwrite branches

git copy
Copy a git branch locally and remotely
git delete
Delete one or more branches locally and remotely
git rename
Rename a git branch locally and remotely

By default, the branches develop and master are protected - they are not allowed to be copied to, renamed, or deleted.

You can configure this in three ways:

  • setting the --all/-a flag ignore protected branches entirely
  • setting the environment variable GITZ_PROTECTED_BRANCHES overrides these defaults
  • setting a value for the keys PROTECTED_BRANCHES in the file .gitz.json in the top directory of your Git project has the same effect

Dangerous commands that rewrite history

Slice, dice, shuffle and split your commits.

These commands are not intended for use on a shared or production branch, but can significantly speed up rapid development on private branches.

git adjust
Amend any commit, not just the last
git permute
Reorder and delete commits in the current branch
git split
Split a range of commits into many single-file commits
git update
Update branches from a reference branch

gitz's People

Contributors

lunaticocr avatar platypew avatar rec avatar sourcery-ai-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

gitz's Issues

Test error handling for each command

  • wrong number of arguments
  • invalid commit IDs
  • cherry picks with conflicts
  • flags with wrong arguments
  • flags with correct arguments! (not really tested)
  • non-existent or wrong type files or directories
  • not in a git hierarchy - new test in Git!
  • errors in individual commands in Git all

Formatting issues in output

  1. There's an extra space for $ in some cases...!

  2. The lines need a \n when they get joined together.

From git delete --verbose foo bar:

 $ git diff-index --quiet HEAD --

 $ git symbolic-ref --short HEAD
 bar
 $ git branch --format="%(refname:short)"
 barfoomastersingle_file
  $ git remote
  origin
  $ git checkout master
  Your branch is ahead of 'origin/master' by 1 commit.
 ERROR:git-delete: ? Switched to branch 'master'
    (use "git push" to publish your local commits)
 $ git branch --format="%(refname:short)"
 barfoomastersingle_file
 $ git remote
 origin
 $ git symbolic-ref --short HEAD
 master
 $ git branch -D foo bar
 Deleted branch foo (was a6b0c3e).Deleted branch bar (was a6b0c3e).
 $ git fetch origin

 $ git branch --format="%(refname:short)" -r
 origin/HEADorigin/_gitz_stripe_0origin/masterorigin/single_file
 git-delete: branches deleted: foo bar

"hidden" should be the default for git commands.

Right now, to run commands with the output suppressed, we use

PROGRAM.hidden.git.branch(...

and the default is verbose:

PROGRAM.git.branch(...

but it should be the other way around, as we almost never want to use verbose output.

Test flags and alternative invocations

The tests are reasonable, but skimpy:

  • They don't test many of the possible flags
  • Sometimes there are many ways to give arguments and we just give one

Automated testing for more of this is need.

`git-split` should handle the staging area

I had a more sophisticated use of the staging area before, which I disabled before I understood what my underlying issue was - it would be a nice feature to have again and probably easy now I understand what I'm doing.

git-delete crash

My guess - it was a file with local branch that hadn't got an upstream.

Traceback (most recent call last):
  File "/code/gitz/git-delete", line 72, in <module>
    git_delete()
  File "/code/gitz/git-delete", line 59, in git_delete
    total_count = git_functions.delete(args.target, PROGRAM, remotes)
  File "/code/gitz/gitz/git_functions.py", line 74, in delete
    git.push(remote, '--delete', target)
  File "/code/gitz/gitz/git.py", line 24, in git
    return util.run('git', *cmd, verbose=self.verbose, **kwds)
  File "/code/gitz/gitz/util.py", line 22, in run
    lines = subprocess.check_output(cmd, **kwds).splitlines()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'git push testing --delete x-sand-3' returned non-zero exit status 1.

Separate usage and help messages

If you type the command wrong, you just want the "usage" - a short reminder of what a command looks like.

You don't want the full help - which can be quite long - unless you explicitly ask for help.

`git-shuffle`: rearrange the recent commits

Examples:

git shuffle   # swaps first and second commits
git shuffle 0123  # no change
git shuffle 3210  # reverses the last 4 changes

Also perhaps:

git shuffle abcd  # no change
git shuffle dcba  # reverses the last 4 changes

?

Uniformize exception handling

We cover most of them, but if any of our main programs gets an unexpected exception, the user gets a bad experience.

Deal with nastiness of `git.GIT.*` vs `git.*`

The division is correct - they are two different things - but the names are confusing.

GIT.* delegates nicely to the actual git command - git.* functions are things unique to this library.

Probably better is splitting the file in two and putting the free functions into, aaaah,git_util.py is such a lame name. gitz, no, confusing of names. git2 urg. git_functions is maybe too long, but probably what I should use.

--dry_run mode

  1. Don't actually run any destructive features
  2. But print out what would have happened.
  3. Would require a new log mode for git.

New git-stripe

git-stripe <#number-of-commits> [branch] [-d/--delete]

Replaces my gbs alias.

Add to new Annoying or abusive category :-D

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.