# git finish helper script delete current branch and update master

When I finished working on feature branch. I can do

```bash
(BRANCH) $ git finish

cleaning up BRANCH
Sure (y/n) ? y
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
Deleted branch BRANCH (was 5a868ef).
Pruning origin
...
Successfully rebased and updated refs/heads/master.

(master) $
```

Put this script to `/usr/local/bin/git-finish`

```bash
#!/bin/bash
branch_name=$(git branch | grep \* | cut -d ' ' -f2)
echo "cleaning up $branch_name"
echo -n "Sure (y/n) ? "
read input < /dev/tty
if [ "$input" == "y" ]; then
  git checkout master
  git branch -D $branch_name
  git remote prune origin
  git fetch origin
  git pull --rebase --autostash
fi
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://til.yulrizka.com/git/git-finish-helper-script-delete-current-branch-and-update-master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
