Add Files to a Repository

Learn how to add new files and folders to a repository.

We'll cover the following

The git add Command#

The add command tells Git to start tracking the files in the local index.

1   git add mycode.py
2   git status
Terminal 1
Terminal

Click to Connect...

You have added a file to the index. It is ready to be committed to the repository.

Remember the four stages you looked at before.

  • You created your file ((1) local changes).
  • You added/staged it to the index (2).

Still, you have no history! Git has simply been made aware of the file, and you must make a commit to initiate Git’s history.

The four stages
3   git log
Terminal 1
Terminal

Click to Connect...

Fatal#

Does the current branch master not have any commits yet? You will need to commit it to the repository to get a history.

Retrieving a Repository's Status
Committing Changes to a Repository
Mark as Completed
Report an Issue