Guest User

Untitled

a guest
Jul 17th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. git add -N new_file
  2. git add -i
  3.  
  4. -N, --intent-to-add
  5. Record only the fact that the path will be added later. An entry
  6. for the path is placed in the index with no content. This is useful
  7. for, among other things, showing the unstaged content of such files
  8. with git diff and committing them with git commit -a.
  9.  
  10. git update-index --add --cacheinfo 100644 $(git hash-object -w /dev/null) newfile
  11. git add --interactive newfile
  12.  
  13. mkdir /tmp/demo
  14. cd /tmp/demo
  15. git init .
  16.  
  17. echo hello > newfile
  18. git update-index --add --cacheinfo 100644 $(git hash-object -w /dev/null) newfile
  19.  
  20. $ find .git/objects/ -type f
  21. .git/objects/e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391
  22.  
  23. $ git status
  24. # On branch master
  25. #
  26. # Initial commit
  27. #
  28. # Changes to be committed:
  29. # (use "git rm --cached <file>..." to unstage)
  30. #
  31. # new file: newfile
  32. #
  33. # Changed but not updated:
  34. # (use "git add <file>..." to update what will be committed)
  35. # (use "git checkout -- <file>..." to discard changes in working directory)
  36. #
  37. # modified: newfile
  38. #
  39.  
  40. $ git diff
  41. diff --git a/newfile b/newfile
  42. index e69de29..ce01362 100644
  43. --- a/newfile
  44. +++ b/newfile
  45. @@ -0,0 +1 @@
  46. +hello
  47.  
  48. git update-index --add --cacheinfo 100644 $(git hash-object -w /dev/null) newfile
  49.  
  50. git add -p # (or --patch)
Add Comment
Please, Sign In to add comment