PyGitUp is a Python implementation of the great
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.
git pull has two problems:
- It merges upstream changes by default, when it's really more polite to rebase over them, 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.
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:
- Windows support.
- Written in Python ;)
How do I install it?
$ pip install git-up
cdto your project's directory.
git upand enjoy!
Note for Windows users:
See these instructions for installing pip, if you haven't already installed it. And don't forget to either:
- make your
Python/Lib/site-packageswritable for you,
pipwith admin privileges
- or use
pip install --user git-upand add
Otherwise pip will refuse to install
git-up due to
Access denied errors.
Python version compatibility:
Python 2.7, 3.3 and 3.4 are supported :)
Options and Configuration
Command Line Arguments
git up -hshows a help message.
git up --quietsuppresses all output except for error messages.
git up --versionshows the current version and optionally checks for updates (see below).
PyGitUp, you can set options in your git config. Run
git config [--global] git-up.[name] [value] to set one of these
git-up.bundler.check [true|*false*]: If set to
PyGitUpwill check your app for any new bundled gems and suggest a
bundle installif necessary.
git-up.bundler.autoinstall [true|*false*]: If set to
bundle installautomatically. Requires
git-up.bundler.checkto be true.
git-up.bundler.local [true|*false*]: If you've
bundle package-ed your project gems, you can tell
bundle install --localfor you if it finds missing gems. Much faster than just a plain old
bundle install. Don't worry if you're missing gems, it will backtrack to
bundle installif anything goes wrong. Make sure
git-up.bundler.autoinstallis also set to
trueor it won't do anything.
git-up.bundler.rbenv [true|*false*]: If you have rbenv installed, you can tell
rbenv rehashfor you after it installs your gems so any binaries will be available right away. Make sure
git-up .bundler.autoinstallis also set to
trueor it won't do anything.
git-up.fetch.prune [*true*|false]: If set to
PyGitUpwill append the
git fetchand thus remove any remote tracking branches which no longer exist on the remote (see git fetch --help).
git-up.fetch.all [true|*false*]: If set to
PyGitUpwill only fetch remotes for which there is at least one local tracking branch. Setting this option will make
git upalways fetch from all remotes, which is useful if e.g. you use a remote to push to your CI system but never check those branches out.
git-up.rebase.arguments [string]: If set,
PyGitUpwill use this string as additional arguments when calling
git rebase. Example:
--preserve-mergesto recreate merge commits in the rebased branch.
git-up.rebase.auto [*true*|false]: If set to
PyGitUpwon't rebase your branches for you but notify you that they diverged. This can be useful if you have a lot of in-progress work that you don't want to deal with at once, but still want to update other branches.
git-up.rebase.log-hook [cmd]: Runs
cmdevery time a branch is rebased or fast-forwarded, with the old head as
$1and the new head as
$2. This can be used to view logs or diffs of incoming changes. Example:
echo "changes on $1:"; git log --oneline --decorate $1..$2.
git-up.rebase.show-hashes [true|*false*]: If set to
PyGitUpwill show the hashes of the current commit (or the point where the rebase starts) and the target commit like
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
falseto turn off the checks.
git-up has been written by aanand:
- Fixed a bug when showing the version on Python 3 #34.
- Support for Python 3 has been added. Thanks @r4ts0n for the Pull Request and @Byron for quickly merging a Pull Request in GitPython and releasing a new version on which this release depends.
- Now updates submodules when called from
git submodule foreach(#8).
- Fixed a problem with
- 3rd party dependencies have been updated
- Added an option to show hashes when fast-forwarding/rebasing like
git pulldoes (
- Fixed a bug when having branches with both local tracking branches and remote tracking branches (#17).
- 3rd party dependencies have been updated to fix a problem with a 3rd party library (#18).
- Fixed some typos in README and
- 3rd party dependencies have been updated.
ahead of upstreammessages are now cyan (see aanand/git-up#60).
- Fixed problem when using % in the log hook (#11).
- Fixed problems with the dependency declaration.
- Fix for #7 (AttributeError: 'GitUp' object has no attribute 'git') introduced by v1.1.0.
Prior to v1.1.0,
PyGitUptried 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,
PyGitUpstops guessing and uses the upstream branch config instead.
This by the way fixes issue #6 (
git updoesn't work with local only branches).
Note: This change may break setups, where a local branch accidently has the same name as a remote branch without any tracking information set. Prior to v1.1.0,
git upwould 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 --versionfrom non-git dirs, too.
PyGitUp reaches 1.0.0. You can consider it stable now :)
- Added a comprehensive test suite, now with a coverage of about 90%.
- Lots of code cleanup.
- Added option
-hto display a help screen (
--helpwon't work, because
gitcatches this option and handles it before
- Added option
--versionto show, what version of
PyGitUpis running. Also checks for updates (can be disabled, see configuration).
- Added option
--quietto be quiet and only display error messages.
- Fixed issue #4 (ugly exception if remote branch has been deleted).
- Fixed issue #3 (didn't return to previous branch).
- Fixed problem: check-bundler.rb has not been installed when installing via PyPI (problems with setup.py).
- Incorporated aanand/git-up#41: Support for
bundle install --localand
- Fixed issue #1 (strange output buffering when having multiple remotes to fetch from).
- Some under-the-hood improvements.
- Initial Release