How to stage only part of a new file with git?

前端 未结 5 1884
猫巷女王i
猫巷女王i 2020-12-02 03:33

I love git add --interactive. It is now part of my daily workflow.

The problem seems that it does not work with untracked files. What I wan

5条回答
  •  北海茫月
    2020-12-02 04:13

    Whoa, all that update-index and hash-object business seems overly complicated. How about this instead:

    git add -N new_file
    git add -i
    

    From git help add:

    -N, --intent-to-add
        Record only the fact that the path will be added later.  An entry
        for the path is placed in the index with no content.  This is useful
        for, among other things, showing the unstaged content of such files
        with git diff and committing them with git commit -a.
    

提交回复
热议问题