Warm tip: This article is reproduced from stackoverflow.com, please click
git github

How to fix Untracked files while pushing a repository on GitHub

发布于 2020-04-07 23:18:48

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.

Questioner
Muhammad Abdullah
Viewed
57
Daniel Farrell 2019-01-03 00:45

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.