An open API service indexing awesome lists of open source software.

https://github.com/michaelaquilina/git-commands

Various helpful git commands for your git workflow
https://github.com/michaelaquilina/git-commands

git productivity

Last synced: 4 months ago
JSON representation

Various helpful git commands for your git workflow

Awesome Lists containing this project

README

          

============
Git Commands
============

|CircleCI| |GPLv3|

Helper commands for git.

* git-web_
* git-clean-branches_
* git-default-branch_
* git-rollback_
* git-commit-status_

Copy any of these commands in to your "$PATH" to make them accessible as a git subcommand

git-web
=======

Opens the relevant web page for the git repository. By default this opens the repository for
the "origin" remote.

Open up a web page for the default origin remote:

.. code:: shell

git web

Open up web page for other specified remote:

.. code:: shell

git web upstream

Open up the issues page:

.. code:: shell

git web --issues

Open up all open pull requests:

.. code:: shell

git web --pulls

Open new pull request for current branch:

.. code:: shell

git web --pull-request

Open commit history

.. code:: shell

git web --commits

Configution
```````````

``git config web.opencommand``: Set the command to use when opening urls by setting

``git config web.default.pulls``: Default fallback url path to use for pull requests

``git config web.default.issues``: Default fallback url path to use for issues

``git config web.default.commits``: Default fallback url path to use for commits

``git config web.$DOMAIN.pulls``: Path to use for pull requests for ``$DOMAIN``

``git config web.$DOMAIN.issues``: Path to use for issues for ``$DOMAIN``

``git config web.$DOMAIN.commits``: Path to use for commit history for ``$DOMAIN``

git-clean-branches
==================

Cleans (delete) any branches that have been been merged into master. This should make
your life easier when figuring out which local branches are no longer important.

Delete all local branches that have been merged into master:

.. code:: shell

git clean-branches

Force delete any branches that might be in an inconistent state:

.. code:: shell

git clean-branches -D

git-default-branch
==================

Prints out the default branch of the repository (typically main or master) by querying
the HEAD of the origin remote.

This is a useful command to have when used in combination with other functions and aliases
you might have.

For example, the alias below would fail on any repositories which do not use main as the
default branch.

.. code:: shell

alias grim="git rebase -i main"

However we can change this to use `git-default-branch` to make it work for any repository:

.. code:: shell

alias grim="git rebase -i $$(git default-branch)"

git-rollback
============

Provides a convenient interactive wrapper around `git reflog` to rollback (via `git reset`).

Accepts and passes through any arguments to the resulting `git reset` command

.. code:: shell

git rollback # performs the default mixed reset on selected commit
git rollback --hard # performs a hard reset on selected commit
git rollback -p # performs an interactive patch reset on selected commit

git-commit-status
=================

Prints the associated commit statuses from your SCM provider for the "origin" remote.

The printed text is hyperlinked within the terminal to allow you to click through
and see details.

Currently only supports github.

.. code:: shell

git commit-status # prints latest branch status by default
git commit-status my-branch-name # supports any ref

.. |CircleCI| image:: https://circleci.com/gh/MichaelAquilina/git-commands.svg?style=svg
:target: https://circleci.com/gh/MichaelAquilina/git-commands

.. |GPLv3| image:: https://img.shields.io/badge/License-GPL%20v3-blue.svg
:target: https://www.gnu.org/licenses/gpl-3.0