Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- git add -N new_file
- git add -i
- -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.
- git update-index --add --cacheinfo 100644 $(git hash-object -w /dev/null) newfile
- git add --interactive newfile
- mkdir /tmp/demo
- cd /tmp/demo
- git init .
- echo hello > newfile
- git update-index --add --cacheinfo 100644 $(git hash-object -w /dev/null) newfile
- $ find .git/objects/ -type f
- .git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
- $ git status
- # On branch master
- #
- # Initial commit
- #
- # Changes to be committed:
- # (use "git rm --cached <file>..." to unstage)
- #
- # new file: newfile
- #
- # Changed but not updated:
- # (use "git add <file>..." to update what will be committed)
- # (use "git checkout -- <file>..." to discard changes in working directory)
- #
- # modified: newfile
- #
- $ git diff
- diff --git a/newfile b/newfile
- index e69de29..ce01362 100644
- --- a/newfile
- +++ b/newfile
- @@ -0,0 +1 @@
- +hello
- git update-index --add --cacheinfo 100644 $(git hash-object -w /dev/null) newfile
- git add -p # (or --patch)
Add Comment
Please, Sign In to add comment