How to fix Untracked files while pushing a repository on GitHub

Viewed 4013

Basically, I have pushed my code to a repository on GitHub. Code has been pushed and upon checking it, I figured out that some files were missing. Then I again tried pushing with the second commit, but I got an error or warning I don't know what was that.

$ git commit -m "second"
On branch master
Untracked files:
        src/app/pages/
        src/app/services/

I was expecting that my files will be pushed, but I got stuck with this error.

3 Answers

the output is from git status. I don't why it's showing during your commit command (maybe it's something you did?) . But it's a great command; I run git status a lot to make sure I've added my new files and know what branch I'm on, etc.

New files within a git repository are not tracked automatically. You just need to git add the files and/or directories you want:

git add src/app/pages src/app/services

Or you can add everything new in src (new files and files modified since their last add) :

git add src

When you're ready to add changes to all tracked files for a commit, that's done with:

git add -u # git add updated files

Or if you really want to add everything,

git add -a

But I always run a git status before . I do that.

This has to do with the initial git remote add.

Once you've initially pushed all the data up (after committing) go ahead and run

git add .

Then recommit and push the data. Your files should then be tracked!

Make sure that you do not have too many terminals open.

Related