如何在git中暂存未跟踪的文件?

时间:2018-03-29 11:07:36

标签: git

当我得到status时,它会在控制台中打印出来。

$ 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")

现在,当我执行git add .时,它会暂存log/production/个文件夹中的所有文件。如果不暂存未跟踪的文件,我该怎么办?

1 个答案:

答案 0 :(得分:1)

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.

相关问题