Arefe
Arefe

Reputation: 12471

How not to stage the untracked files in git?

At the time I get the status, it prints like this in the console.

$ git status
On branch easy_buy_and_sell
Your branch is up-to-date with 'origin/easy_buy_and_sell'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:  xyz/src/main/java/com/draglet/domain/order/LocalOrderImpl.java

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

        log/
        production/

no changes added to commit (use "git add" and/or "git commit -a")

Now, when I execute the git add ., it staged all the files in the log/ and the production/ folders. What can I do for not staging the untracked files?

Upvotes: 0

Views: 369

Answers (1)

harish chava
harish chava

Reputation: 252

Instead of using git add . use git add draglet-common/src/main/java/com/draglet/domain/order/LocalOrderImpl.java

Because git add . stages all the files in working directory.

You can stage individual files by using git add path/to/file1 path/to/file2

You can use git add -u path/to/file1 path/to/file2 to stage modified and deleted files.

Upvotes: 1

Related Questions