> For the complete documentation index, see [llms.txt](https://yu-sun.gitbook.io/essential-git-for-scientists/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yu-sun.gitbook.io/essential-git-for-scientists/basic-operations/extend-a-branch.md).

# Extend a Branch

Branches are comprised of commits. Any new commit is made at the tip of a branch, causing the branch to grow.

Now let's make a commit in the `new` branch:

* A new file is created with `import this` as the content.
* The file is staged and commited

```bash
λ echo import this > newfile.py

λ cat newfile.py
import this

λ git commit -am "Added new file"
On branch new
Untracked files:
  (use "git add <file>..." to include in what will be committed)
        newfile.py
nothing added to commit but untracked files present (use "git add" to track)

λ git commit --am "Added new file"
error: pathspec 'Added new file' did not match any file(s) known to git

λ git add newfile.py

λ git commit -m "Added new file"
[new e84601c] Added new file
 1 file changed, 1 insertion(+)
 create mode 100644 newfile.py
```

If we look at the commit history now, you will see HEAD is pointing to `new` and it's one commit ahead of `master`.

```bash
λ git log --oneline
e84601c (HEAD -> new) Added new file
a37231a (master) Revert "Added another file"
35ac407 Added another file
ee7ebbd Print out the std dev
b1e55d3 Print out the mean
c96c526 First commit
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://yu-sun.gitbook.io/essential-git-for-scientists/basic-operations/extend-a-branch.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
