msiemens / PyGitUp

A nicer `git pull`
MIT License
528 stars 41 forks source link
git python

PyGitUp |Version| |Build Status| |Coverage Status|

|PyGitUp|_ is a Python port of aanand/git-up <https://github.com/aanand/git-up/>__. It not only fully covers the abilities of git-up and should be a drop-in replacement, but also extends it slightly.

.. |PyGitUp| replace:: PyGitUp .. _PyGitUp: https://github.com/msiemens/PyGitUp

Why use git up?

git pull has two problems:

* It merges upstream changes by default, when it's really more polite to `rebase
  over them <http://gitready.com/advanced/2009/02/11/pull-with-rebase.html>`__,
  unless your collaborators enjoy a commit graph that looks like bedhead.

* It only updates the branch you're currently on, which means git push will
  shout at you for being behind on branches you don't particularly care about
  right now.

(https://github.com/aanand/git-up/)

Demonstration

.. image:: http://i.imgur.com/EC3pvYu.gif

Why use the Python port?

I wasn't able to use the original git-up, because I didn't want to install a whole Ruby suite just for git-up and even with Ruby installed, there were some problems running on my Windows machine. So, my reasons for writing and using this port are:

  1. Windows support.
  2. Written in Python ;)

How do I install it?

  1. Install git-up via pip <https://pip.pypa.io/en/latest/installing.html>__: $ pip install git-up
  2. cd to your project's directory.
  3. Run git up and enjoy!

Homebrew users can also use brew: brew install pygitup

How to run it locally?

Could also checkout the .github/workflows/ci-workflow.yml

  1. clone repo and cd to repo directory.
  2. Install poetry as guided by poetry installation doc <https://python-poetry.org/docs/#installation>__
  3. Run poetry install
  4. Run program with poetry run git-up
  5. Run all tests with poetry run pytest -v --cov=PyGitUp or poetry run pytest -v --cov=PyGitUp --cov-report html
  6. Run one test with poetry run pytest -q PyGitUp/tests/test_version.py -v --cov=PyGitUp

Note for Windows users:


See `these instructions <http://stackoverflow.com/q/4750806/997063>`__
for installing pip, if you haven't already installed it. And don't forget
to either:

- make your ``Python/Scripts`` and ``Python/Lib/site-packages`` writable for
  you,
- run ``pip`` with admin privileges
- or use ``pip install --user git-up`` and add ``%APPDATA%/Python/Scripts``
  to ``%PATH%``.

Otherwise pip will refuse to install ``git-up`` due to ``Access denied`` errors.

Python version compatibility:

Python 3.7 and upwards are supported :)

Options and Configuration

Command Line Arguments


- ``git up -h`` shows a help message.

- ``git up --quiet`` suppresses all output except for error messages.

- ``git up --no-fetch`` skips fetching the remote and rebases all local branches.

- ``git up --version`` shows the current version and optionally checks for
  updates (see below).

Configuration

To configure PyGitUp, you can set options in your git config. Run git config [--global] git-up.[name] [value] to set one of these options:

New in v1.0.0:


- ``git-up.updates.check [*true*|false]``: When running ``git up --version``,
  it shows the version number and checks for updates. If you feel
  uncomfortable with it, just set it to ``false`` to turn off the checks.

Credits
-------

The original ``git-up`` has been written by aanand:
`aanand/git-up/ <https://github.com/aanand/git-up/>`__.

Changelog
---------

v2.2.0 (*2022-11-21*)

v2.1.0 (2021-10-02)


- Switch to Python's ``argparse`` for CLI argument parsing. Thanks
  `@ekohl <https://github.com/ekohl>`_ for `Pull Request #96
  <https://github.com/msiemens/PyGitUp/pull/96>`_.

v2.0.3 (*2021-09-23*)

v2.0.2 (2020-12-30)


- Remove old Python 2 code. Thanks `@hugovk <https://github.com/hugovk>`_
  for `Pull Request #104 <https://github.com/msiemens/PyGitUp/pull/104>`_.

v2.0.1 (*2020-08-26*)

v2.0.0 (2020-08-15)


- Drop Python 2 support in order to fix `Issue 102 <https://github.com/msiemens/PyGitUp/issues/102>`_
- Drop Ruby Bundler integration
- Migrate tests to ``py.test``

v1.6.1 (*2018-12-12*)

v1.6.0 (2018-10-26)


- Skip stashing changes when possible. Thanks `@Chronial <https://github.com/Chronial>`_
  for `Pull Request #86 <https://github.com/msiemens/PyGitUp/pull/86>`_.
- Added faster fast-forward on branches that are not checked out. Thanks `@Chronial <https://github.com/Chronial>`_
  for `Pull Request #83 <https://github.com/msiemens/PyGitUp/pull/83>`_.

v1.5.2 (*2018-09-28*)

v1.5.1 (2018-09-13)


- Fixed crash on Cygwin with rebase log hook enabled (`#80 <https://github.com/msiemens/PyGitUp/issues/80>`__).

v1.5.0 (*2018-04-26*)

v1.4.7 (2018-04-07)


- Added shorthand commandline arguments (``-V, -q, -h``, see `#73 <https://github.com/msiemens/PyGitUp/issues/73>`__).

v1.4.6 (*2017-12-19*)

v1.4.5 (2017-01-02)


- Fixed problems when working with branches containing hash signs in their name
  (`#55 <https://github.com/msiemens/PyGitUp/issues/55>`__).
- No longer installs a now unneeded script on ``pip install``. Thanks `@ekohl <https://github.com/ekohl>`_
  for `Pull Request #60 <https://github.com/msiemens/PyGitUp/pull/60>`_.

v1.4.4 (*2016-11-30*)

v1.4.3 (2016-11-22)


- Fixed a bug with GitPython <= 2.0.8 (`#56 <https://github.com/msiemens/PyGitUp/issues/56>`__, `#57 <https://github.com/msiemens/PyGitUp/issues/57>`__).

v1.4.2 (*2016-09-29*)

v1.4.1 (2016-08-02)


- Include tests in PyPI distribution (`#51 <https://github.com/msiemens/PyGitUp/issues/51>`__).

v1.4.0 (*2016-02-29*)

v1.3.1 (2015-08-31)


- Fixed a bug when showing the version on Python 3 `#34 <https://github.com/msiemens/PyGitUp/issues/34>`__.

v1.3.0 (*2015-04-08*)

v1.2.2 (2015-02-23)


- Now updates submodules when called from ``git submodule foreach`` (`#8 <https://github.com/msiemens/PyGitUp/issues/8>`__).

v1.2.1 (*2014-12-16*)

v1.2.0 (2014-12-10)


- Added an option to show hashes when fast-forwarding/rebasing like ``git pull``
  does (``git-up.rebase.show-hashes``).
- Fixed a bug when having branches with both local tracking branches and
  remote tracking branches (`#17 <https://github.com/msiemens/PyGitUp/issues/17>`__).

v1.1.5 (*2014-11-19*)

v1.1.4 (2014-04-18)


- Fixed some typos in README and ``PyGitUp`` output.
- 3rd party dependencies have been updated.

v1.1.3 (*2014-03-23*)

v1.1.2 (2013-10-08)


- Fixed problems with the dependency declaration.

v1.1.1 (*2013-10-07*)

v1.1.0 (2013-10-07)


- Prior to v1.1.0, ``PyGitUp`` tried to guess the upstream branch for a local
  branch by looking for a branch on any remote with the same name. With v1.1.0,
  ``PyGitUp`` stops guessing and uses the upstream branch config instead.

  This by the way fixes issue `#6 <https://github.com/msiemens/PyGitUp/issues/6>`__
  (``git up`` doesn't work with local only branches).

  **Note:**
  This change may break setups, where a local branch accidentally has
  the same name as a remote branch without any tracking information set. Prior
  to v1.1.0, ``git up`` would still fetch and rebase from the remote branch.
  If you run into troubles with such a setup, setting tracking information
  using ``git branch -u <remote>/<remote branch> <local branch>`` should help.

- 3rd party dependencies have been updated.

- Allows to run ``git up --version`` from non-git dirs, too.

v1.0.0 (*2013-09-05*)

Finally PyGitUp reaches 1.0.0. You can consider it stable now :)

v0.2.3 (2013-06-05)


- Fixed issue `#4 <https://github.com/msiemens/PyGitUp/issues/4>`__ (ugly
  exception if remote branch has been deleted).

v0.2.2 (*2013-05-04*)

v0.2.1 (2013-03-18)


- Fixed problem: check-bundler.rb has not been installed when installing via
  PyPI (problems with setup.py).

v0.2 (*2013-03-18*)

v0.1 (2013-03-14)



- Initial Release

.. |Build Status| image:: https://img.shields.io/azure-devops/build/msiemens/3e5baa75-12ec-43ac-9728-89823ee8c7e2/1.svg?style=flat-square
   :target: https://dev.azure.com/msiemens/github/_build?definitionId=1

.. |Coverage Status| image:: http://img.shields.io/coveralls/msiemens/PyGitUp/master.svg?style=flat-square
  :target: https://coveralls.io/r/msiemens/PyGitUp

.. |Version| image:: http://img.shields.io/pypi/v/git-up.svg?style=flat-square
  :target: https://pypi.python.org/pypi/git-up