Skip to content
Snippets Groups Projects
Name Last commit Last update
bin
.editorconfig
.gitignore
README.md

Git Scripts

Scripts that extend git and make our git workflow a bit easier.

Installation

Clone this repository and add the bin subdir to your path.

Usage

git defaultbranch

Returns the default branch of the upstream repository. Returns master if it cannot be determined.

$ git defaultbranch
develop

git reset-to-default

Softly resets the current branch to its common ancestor with the default branch. This is useful for reviewing code locally (i.e. in your IDE), since the resulting diff with identical of a merge request of the current branch to the default branch.

git reset-to-origin

Does a hard reset of the current branch to its reference of the corresponding remote branch. This is effectively the inverse operation of git reset-to-default, and is useful is you want to stop reviewing code locally.

git lastbranch

Sort branches by last commit date and show if they're merged into the default branch.

$ git lastbranch
* develop                               8 days ago [default]
  fsureau/bugfix/DM_LE3_nofixval        9 weeks ago [merged]
  master                                4 months ago
  release/1.8                           5 months ago
  tnutma/bugfix/fixcircularsysimport    6 months ago [merged]
  tnutma/bugfix/movegrismoncemore       6 months ago [merged]
  tnutma/bugfix/sequencecardinality/vis 8 months ago
  tn/ruleupdate/noversion               9 months ago
  tn/ruleupdate/noversions              9 months ago
  tnutma/bugfix/noabstracttypes         10 months ago
  tnutma/bugfix/absoluteschemalocation  10 months ago
  pre-migration/develop                 11 months ago [merged]
  release/1.6.7-validation              1 year, 5 months ago [merged]

git delete-merged [--dry-run] [--keep <regex of branches to keep>]

Deletes local branches that have been merged into the default branch:

$ git delete-merged --dry-run
Would delete the following merged branches:

fsureau/bugfix/DM_LE3_nofixval
release/1.6.7-validation
tnutma/bugfix/fixcircularsysimport
tnutma/bugfix/movegrismoncemore

git log-mr [<revision range>]

Show a log of merged MRs.

$ git log-mr
commit e502910bbbcca74ed59b6ea0dd7c4e9f1e54dcaf
Merge request: !199
Reviewer:      Teake Nutma <nutma@astro.rug.nl>
Contributors:  Martin Wiesmann <martin.wiesmann@astro.uio.no>,
Contents:      2 commits, 1 file changed, 184 insertions(+), 177 deletions(-)
Source branch: mwiesman/feature/listLimit
Target branch: develop

    moved min/max limits to single elements of list of flags

commit b5c3c5527acb25615a32de1125bf662e8d0c4427
Merge request: !194
Reviewer:      Christophe Dabin <christophe.dabin@cnes.fr>
Contributors:  Florent Sureau <florent.sureau@cea.fr>,
Contents:      4 commits, 9 files changed, 27 insertions(+), 110 deletions(-)
Source branch: fsureau/bugfix/DM_LE3_nofixval
Target branch: develop

    Removed fixed values in types and products