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 log-mr [--output log|markdown] [<revision range>]
Show a log of merged MRs. Useful for determining which MRs have not yet landed into a release branch. The output of this command is then in effect a change log:
$ git log-mr origin/release-8.0..origin/develop
[33mcommit 4d800c89296b21f28efba2aa2d2fd7c6ad50cab6[0m
Merge request: !180
Reviewer: Christophe Dabin <christophe.dabin@cnes.fr>
Contributors: Kevin Benson <k.benson@ucl.ac.uk>
Contents: 2 commits, 1 file changed, 33 insertions(+), 13 deletions(-)
Source branch: kbenson/feature/vis_sc8_cti
Target branch: develop
Kbenson/feature/vis sc8 cti
The output can also be Markdown, so that it can be easily copy-pasted into GitLab MR descriptions:
$ git log-mr
### !180 Kbenson/feature/vis sc8 cti
* 2 commits.
* 1 file changed, 33 insertions(+), 13 deletions(-).
* Contributors: Kevin Benson.
* Reviewed by Christophe Dabin.
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