Guest User

Untitled

a guest
Oct 15th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. $ git init
  2. Initialized empty Git repository in /.../git-history/.git/
  3. $ mkdir dir1
  4.  
  5. $ nano dir1/file.txt # File version 1
  6. $ git add dir1/file.txt
  7. $ git commit -m "First version of the file"
  8. [master (root-commit) 27a260b] First version of the file
  9. 1 file changed, 2 insertions(+)
  10. create mode 100644 dir1/file.txt
  11.  
  12. $ nano dir1/file.txt # File version 2
  13. $ git commit -am "Second version of the file"
  14. [master bab5759] Second version of the file
  15. 1 file changed, 1 insertion(+), 1 deletion(-)
  16.  
  17. $ git mv dir1 dir2 # Move the file around
  18. $ git commit -m "dir1 -> dir2"
  19. [master c9d9b87] dir1 -> dir2
  20. 1 file changed, 0 insertions(+), 0 deletions(-)
  21. rename {dir1 => dir2}/file.txt (100%)
  22.  
  23. $ nano dir2/file.txt # File version 3
  24. $ git commit -am "Third version of the file"
  25. [master 2c3506e] Third version of the file
  26. 1 file changed, 1 insertion(+), 1 deletion(-)
  27.  
  28. $ git log dir2/file.txt # git log without follow omits history
  29. commit 2c3506eb4ebb62e164522aa50196e5d47d2e4ffd
  30. Author: Evan Driscoll <driscoll@cs.wisc.edu>
  31. Date: Tue Sep 4 17:16:46 2012 -0500
  32. Third version of the file
  33.  
  34. commit c9d9b87c8fefd5bc1ba64b6fb9944df138981a4a
  35. Author: Evan Driscoll <driscoll@cs.wisc.edu>
  36. Date: Tue Sep 4 17:16:24 2012 -0500
  37.  
  38. dir1 -> dir2
  39.  
  40. $ git log --follow dir2/file.txt # but git log --follow includes it
  41. commit 2c3506eb4ebb62e164522aa50196e5d47d2e4ffd
  42. Author: Evan Driscoll <driscoll@cs.wisc.edu>
  43. Date: Tue Sep 4 17:16:46 2012 -0500
  44.  
  45. Third version of the file
  46.  
  47. commit c9d9b87c8fefd5bc1ba64b6fb9944df138981a4a
  48. Author: Evan Driscoll <driscoll@cs.wisc.edu>
  49. Date: Tue Sep 4 17:16:24 2012 -0500
  50.  
  51. dir1 -> dir2
  52.  
  53. commit bab57593d60a25206bd987e9be3a42fd4d917b70
  54. Author: Evan Driscoll <driscoll@cs.wisc.edu>
  55. Date: Tue Sep 4 17:16:06 2012 -0500
  56.  
  57. Second version of the file
  58.  
  59. commit 27a260b1ae80ad7d96e9d802d2dd83dd0c9be18e
  60. Author: Evan Driscoll <driscoll@cs.wisc.edu>
  61. Date: Tue Sep 4 17:15:51 2012 -0500
  62.  
  63. First version of the file
  64.  
  65. $ git filter-branch --subdirectory-filter dir2 -- --all # filter that directory
  66. Rewrite 2c3506eb4ebb62e164522aa50196e5d47d2e4ffd (2/2)
  67. Ref 'refs/heads/master' was rewritten
  68.  
  69. $ ls
  70. file.txt
  71.  
  72. $ git log file.txt # git log without follow omits history
  73. commit 65fee0bb46885e15648a11f6e5676a3a606c5a2f # (as expected)
  74. Author: Evan Driscoll <driscoll@cs.wisc.edu>
  75. Date: Tue Sep 4 17:16:46 2012 -0500
  76.  
  77. Third version of the file
  78.  
  79. commit 5c56a9bf5ea86eb4b32f47fd62cca64a9c6a8171
  80. Author: Evan Driscoll <driscoll@cs.wisc.edu>
  81. Date: Tue Sep 4 17:16:24 2012 -0500
  82.  
  83. dir1 -> dir2
  84.  
  85. $ git log --follow file.txt # but now git log --follow also omits
  86. commit 65fee0bb46885e15648a11f6e5676a3a606c5a2f # history
  87. Author: Evan Driscoll <driscoll@cs.wisc.edu>
  88. Date: Tue Sep 4 17:16:46 2012 -0500
  89.  
  90. Third version of the file
  91.  
  92. commit 5c56a9bf5ea86eb4b32f47fd62cca64a9c6a8171
  93. Author: Evan Driscoll <driscoll@cs.wisc.edu>
  94. Date: Tue Sep 4 17:16:24 2012 -0500
  95.  
  96. dir1 -> dir2
Add Comment
Please, Sign In to add comment