Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $ git init
- Initialized empty Git repository in /.../git-history/.git/
- $ mkdir dir1
- $ nano dir1/file.txt # File version 1
- $ git add dir1/file.txt
- $ git commit -m "First version of the file"
- [master (root-commit) 27a260b] First version of the file
- 1 file changed, 2 insertions(+)
- create mode 100644 dir1/file.txt
- $ nano dir1/file.txt # File version 2
- $ git commit -am "Second version of the file"
- [master bab5759] Second version of the file
- 1 file changed, 1 insertion(+), 1 deletion(-)
- $ git mv dir1 dir2 # Move the file around
- $ git commit -m "dir1 -> dir2"
- [master c9d9b87] dir1 -> dir2
- 1 file changed, 0 insertions(+), 0 deletions(-)
- rename {dir1 => dir2}/file.txt (100%)
- $ nano dir2/file.txt # File version 3
- $ git commit -am "Third version of the file"
- [master 2c3506e] Third version of the file
- 1 file changed, 1 insertion(+), 1 deletion(-)
- $ git log dir2/file.txt # git log without follow omits history
- commit 2c3506eb4ebb62e164522aa50196e5d47d2e4ffd
- Author: Evan Driscoll <driscoll@cs.wisc.edu>
- Date: Tue Sep 4 17:16:46 2012 -0500
- Third version of the file
- commit c9d9b87c8fefd5bc1ba64b6fb9944df138981a4a
- Author: Evan Driscoll <driscoll@cs.wisc.edu>
- Date: Tue Sep 4 17:16:24 2012 -0500
- dir1 -> dir2
- $ git log --follow dir2/file.txt # but git log --follow includes it
- commit 2c3506eb4ebb62e164522aa50196e5d47d2e4ffd
- Author: Evan Driscoll <driscoll@cs.wisc.edu>
- Date: Tue Sep 4 17:16:46 2012 -0500
- Third version of the file
- commit c9d9b87c8fefd5bc1ba64b6fb9944df138981a4a
- Author: Evan Driscoll <driscoll@cs.wisc.edu>
- Date: Tue Sep 4 17:16:24 2012 -0500
- dir1 -> dir2
- commit bab57593d60a25206bd987e9be3a42fd4d917b70
- Author: Evan Driscoll <driscoll@cs.wisc.edu>
- Date: Tue Sep 4 17:16:06 2012 -0500
- Second version of the file
- commit 27a260b1ae80ad7d96e9d802d2dd83dd0c9be18e
- Author: Evan Driscoll <driscoll@cs.wisc.edu>
- Date: Tue Sep 4 17:15:51 2012 -0500
- First version of the file
- $ git filter-branch --subdirectory-filter dir2 -- --all # filter that directory
- Rewrite 2c3506eb4ebb62e164522aa50196e5d47d2e4ffd (2/2)
- Ref 'refs/heads/master' was rewritten
- $ ls
- file.txt
- $ git log file.txt # git log without follow omits history
- commit 65fee0bb46885e15648a11f6e5676a3a606c5a2f # (as expected)
- Author: Evan Driscoll <driscoll@cs.wisc.edu>
- Date: Tue Sep 4 17:16:46 2012 -0500
- Third version of the file
- commit 5c56a9bf5ea86eb4b32f47fd62cca64a9c6a8171
- Author: Evan Driscoll <driscoll@cs.wisc.edu>
- Date: Tue Sep 4 17:16:24 2012 -0500
- dir1 -> dir2
- $ git log --follow file.txt # but now git log --follow also omits
- commit 65fee0bb46885e15648a11f6e5676a3a606c5a2f # history
- Author: Evan Driscoll <driscoll@cs.wisc.edu>
- Date: Tue Sep 4 17:16:46 2012 -0500
- Third version of the file
- commit 5c56a9bf5ea86eb4b32f47fd62cca64a9c6a8171
- Author: Evan Driscoll <driscoll@cs.wisc.edu>
- Date: Tue Sep 4 17:16:24 2012 -0500
- dir1 -> dir2
Add Comment
Please, Sign In to add comment