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

λ 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.

Last updated