Home Explore Blog CI



nushell

1st chunk of `cookbook/git.md`
6a75356c68f81651b19fc7d4099dcaa053665c1fc8be85870000000100000b39
---
title: Git
---

# Git

Nu can help with common `Git` tasks like removing all local branches which have been merged into master.

### Delete git merged branches

**Warning**: This command will hard delete the merged branches from your machine. You may want to check the branches selected for deletion by omitting the last git command.

```nu
git branch --merged | lines | where ($it != "* master" and $it != "* main") | each {|br| git branch -D ($br | str trim) } | str trim
# => ───┬───────────────────────────────────────────
# =>  0 │ Deleted branch start_urls (was fc01bb45).
# => ───┴───────────────────────────────────────────
```

Parse formatted commit messages (more details in the parsing git log section)

```nu
git log --pretty=%h»¦«%aN»¦«%s»¦«%aD | lines | split column "»¦«" sha1 committer desc merged_at | first 10
# => ───┬──────────┬───────────────────┬───────────────────────────────────────────────────────┬─────────────────────────────────
# =>  # │   sha1   │     committer     │                         desc                          │            merged_at
# => ───┼──────────┼───────────────────┼───────────────────────────────────────────────────────┼─────────────────────────────────
# =>  0 │ 42f1874a │ Justin Ma         │ Update some examples and docs (#4682)                 │ Tue, 1 Mar 2022 21:05:29 +0800
# =>  1 │ 2a89936b │ Sophia            │ Move to latest stable crossterm, with fix (#4684)     │ Tue, 1 Mar 2022 07:05:46 -0500
# =>  2 │ ece5e7db │ Fernando Herrera  │ dataframe list command (#4681)                        │ Tue, 1 Mar 2022 11:41:13 +0000
# =>  3 │ a6a96b29 │ Sophia            │ Add binary literals (#4680)                           │ Mon, 28 Feb 2022 18:31:53 -0500
# =>  4 │ e3100e6a │ Luca Trevisani    │ Fix alias in `docs/sample_config/config.toml` (#4669) │ Mon, 28 Feb 2022 22:47:14 +0100
# =>  5 │ cb5c61d2 │ Sophia            │ Fix open ended ranges (#4677)                         │ Mon, 28 Feb 2022 11:15:31 -0500
# =>  6 │ b09acdb7 │ Justin Ma         │ Fix unsupported type message for some math related    │ Mon, 28 Feb 2022 23:14:33 +0800

Title: Git Integration in Nushell
Summary
Nushell can be used to automate common Git tasks, such as deleting merged local branches and parsing formatted commit messages. Examples are provided for both scenarios, demonstrating how to use Nushell commands to interact with Git.