What are these untracked files showing up that I didn't create?

Question

When I do git status, several files show up in red that I didn’t create, like ‘init_test.rb.’ What are these files?

Answer

These are files created by Codecademy’s environment to check that you’re completing the exercises successfully. They’re not part of the project and don’t need to be considered.

However, they do offer a valuable lesson! When you’re working with a project that generates files that you aren’t interested in tracking with your Git repo, you don’t always have to add them, and it’s okay for them to remain red.

For example, often at times you’ll use a .gitignore file and specify file types to be ignored by Git. These will be file types that are generated for logging, by your operating system, or any other file that doesn’t need to be tracked and maintained as part of the essential project. It’s just good to be mindful of the fact that such files can be generated, so using git status to see what files are modified is a good way to keep track of that.

16 Likes

The first line of git status shows “On branch master”. What does it mean? Please explain.

2 Likes

A branch in git is simply put, an independent line/path of development.
The line consists of references (pointers) to your git commit snapshots.
It may help to visualize these snapshots as aligning in a “branch”/sideways flowchart-like structure.
The master branch is the main (default) branch.
The master branch can “branch off” into smaller “twigs” of individual branches.
These smaller branches can later be merged (synced) back into the master branch.

The git status line “On branch master”, basically means that your commit is connected to the default/master branch.

Example: Two people both work on the same coding project. The project lie on the master branch.
Person A is tasked with fixing bugs in the project.
Person B is tasked with adding new features to the project.
In order to be able to work parallel on the project. They both create their own separate branches that points to their respective Git Commits, which in turn keep track of their own individual changes to the code. This way, they won’t risk messing up the main project on the master branch.
After they have made sure it’s safe to sync up their changes to the main project, they can then (in turn) merge their own branches with the master branch.

To better understand the concept, here are some resources:
https://www.codecademy.com/learn/learn-git/modules/learn-git-git-branching-u
https://www.atlassian.com/git/tutorials/using-branches
https://git-scm.com/book/en/v1/Git-Branching-What-a-Branch-Is
https://learngitbranching.js.org

14 Likes

Hi,
When I type git status, it shows nothing but this

fatal: not a git repository (or any of the parent directories): .git 

what is that mean? Did I do wrong?

2 Likes

just find out in the next step
https://discuss.codecademy.com/t/why-am-i-unable-to-git-add-a-file/361676

1 Like

If you are getting this error:

fatal: not a git repository (or any of the parent directories): .git

The solution that worked for me to get the expected result:

On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)

        scene-1.txt

nothing added to commit but untracked files present (use "git add" to track)

Was going back to lesson two and entered git init again, probably works if you do it on this lesson too! :nerd_face:

1 Like

If you are seeing this after typing git status: Not a git repository (or any of the parent directories): .git

Start including git innit ( press enter) then add git status (press enter). Then you will then see the following:
On branch master

Initial commit

Untracked files:
(use “git add …” to include in what will be committed)

    init_test.rb
    scene-1.txt

nothing added to commit but untracked files present (use “git add” to track)


why does my code show this?